Skip to content

Commit

Permalink
Have to parse JWTs as MapClaims now, as that's what the printer expects
Browse files Browse the repository at this point in the history
  • Loading branch information
mt-inside committed Feb 8, 2024
1 parent 420c0ed commit 2521341
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/enricher/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func OIDCInfo(ctx context.Context, d *state.RequestData) (found bool, err error,

token, _, err = parser.ParseUnverified(
cookie.Value,
&jwt.RegisteredClaims{},
&jwt.MapClaims{},
)

if errors.Is(err, jwt.ErrTokenMalformed) {
Expand Down Expand Up @@ -239,7 +239,7 @@ func OIDCInfo(ctx context.Context, d *state.RequestData) (found bool, err error,

token, err = parser.ParseWithClaims(
cookie.Value,
&jwt.RegisteredClaims{},
&jwt.MapClaims{},
func(token *jwt.Token) (interface{}, error) {
kid := token.Header["kid"].(string)
jwksKey, ok := pubKeys[kid]
Expand Down
4 changes: 2 additions & 2 deletions pkg/parser/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func JWT(ctx context.Context, r *http.Request, validateKey crypto.PublicKey) (to
if validateKey != nil {
token, tokenErr = parser.ParseWithClaims(
str,
&jwt.RegisteredClaims{},
&jwt.MapClaims{},
func(token *jwt.Token) (interface{}, error) { return validateKey, nil },
)
} else {
Expand All @@ -57,7 +57,7 @@ func JWT(ctx context.Context, r *http.Request, validateKey crypto.PublicKey) (to
// The function to do that claims validation is private in the v5 API, with a comment saying it might be made public later (in v4 we could call it)
token, _, tokenErr = parser.ParseUnverified(
str,
&jwt.RegisteredClaims{},
&jwt.MapClaims{},
)
// TODO: validate the claims, when validation function is public
}
Expand Down

0 comments on commit 2521341

Please sign in to comment.