-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Describe the bug
OidcIdTokenDecoderFactory by default defines jwsAlgorithmResolver with RS256 as signature algorithm for Signed JWTs (here at
Line 86 in 1edfa07
private Function<ClientRegistration, JwsAlgorithm> jwsAlgorithmResolver = ( |
It provides a setter method to override and supply your own algorithm resolver (here at
Line 221 in 1edfa07
public void setJwsAlgorithmResolver(Function<ClientRegistration, JwsAlgorithm> jwsAlgorithmResolver) { |
However, the way jwtAlgorithmResolver is being used to create NimbusJwtDecoder in buildDecoder() function (here
Line 140 in 1edfa07
private NimbusJwtDecoder buildDecoder(ClientRegistration clientRegistration) { |
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.