Skip to content

Commit 15b225a

Browse files
author
jhorecny-figure
authored
Merge pull request #10 from provenance-io/jh/support-standard-bearer-auth
support standard Bearer token header format
2 parents 8800f90 + b34a08a commit 15b225a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

jwt-wallet.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package jwtwallet
33
import (
44
"encoding/json"
55
"fmt"
6+
"strings"
67

78
"github.com/provenance-io/kong-jwt-wallet/grants"
89
"github.com/provenance-io/kong-jwt-wallet/signing"
@@ -45,7 +46,14 @@ func (conf Config) Access(kong *pdk.PDK) {
4546
return
4647
}
4748

48-
tok, err := handleToken(kong, header)
49+
authToken := strings.Split(header, "Bearer")
50+
if len(authToken) < 2 {
51+
kong.Log.Warn("malformed auth header")
52+
kong.Response.Exit(401, "{}", x)
53+
return
54+
}
55+
56+
tok, err := handleToken(kong, strings.TrimSpace(authToken[1]))
4957
if err != nil {
5058
kong.Log.Warn("err:" + err.Error())
5159
kong.Response.Exit(401, "{}", x)

0 commit comments

Comments
 (0)