Skip to content

Commit

Permalink
Add comment re: why key algorithm inference is necessary
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Haugrud <[email protected]>
  • Loading branch information
erik-h committed Apr 15, 2024
1 parent c80d7f4 commit 54013aa
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/authz/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,8 @@ func (o *oidcHandler) isValidIDToken(ctx context.Context, log telemetry.Logger,
return false, codes.Internal
}

// We use jws.WithInferAlgorithmFromKey(true) in case the keys are missing the "alg" value;
// some providers (e.g. Microsoft Identity) exclude the "alg" value from their keys.
if _, err := jws.Verify([]byte(idTokenString), jws.WithKeySet(jwtSet, jws.WithInferAlgorithmFromKey(true))); err != nil {
log.Error("error verifying id token with fetched jwks", err)
return false, codes.Internal
Expand Down

0 comments on commit 54013aa

Please sign in to comment.