Skip to content

OidcIdTokenDecoderFactory allows only one algorithm (default to RS256) to be specified for JWT Decoder. Doesn't work when there are multiple algorithms used by IDP to issue signed JWT Tokens #11049

@jigneshshukla

Description

@jigneshshukla

Describe the bug
OidcIdTokenDecoderFactory by default defines jwsAlgorithmResolver with RS256 as signature algorithm for Signed JWTs (here at

)

It provides a setter method to override and supply your own algorithm resolver (here at

public void setJwsAlgorithmResolver(Function<ClientRegistration, JwsAlgorithm> jwsAlgorithmResolver) {
).

However, the way jwtAlgorithmResolver is being used to create NimbusJwtDecoder in buildDecoder() function (here

) , it enforces only one algorithm to be supplied to NimbusJwtDecoder which it uses internally during the key selection process.

This implementation works fine if IDP uses only one algorithm at a time as in that case, we can customize the algorithm to be used by supplying your custom jwtAlgorithmResolver using setJwsAlgorithmResolver() setter method.

However, if IDP uses more than one algorithms to sign ID Token, there is no way we can supply all the algorithms used by IDP and so the token processing fails during the whole OIDC based authentication process when a token is signed with a different algorithm than what's used to initialize NimbusJwtDecoder through OidcIdTokenDecoderFactory.

To Reproduce
Have IDP use more than one algorithm (say RS256 and ES256 both) to sign JWT and make sure it randomly alternates between these algorithms for oidc based authentication request flow.

Expected behavior
As long as user has authenticated successfully, the client app should be able to process and validate IDTokens regardless of which algorithm was used out of the set of configured algorithms.

Sample

Unfortunately, I can't share any code as it's private to the organization I work for, however, I'll update this ticket if I can somehow create a sample with some public IDP (e.g. google) where I can configure multiple algorithms.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions