Skip to content

JwtDecoders and ReactiveJwtDecoders should determine algorithm from JWK Set Endpoint #7160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jzheaux opened this issue Jul 29, 2019 · 3 comments
Assignees
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Milestone

Comments

@jzheaux
Copy link
Contributor

jzheaux commented Jul 29, 2019

JwtDecoder and ReactiveJwtDecoder could be improved by determining the JWS algorithm from the JWK Set endpoint.

This is something already supported in Nimbus via:

URL url = new URL("https://idp.example.org/.well-known/jwks.json");
JWSKeySelector selector = 
        JWSAlgorithmFamilyJWSKeySelector.fromJWKSetURL(url);

The result would be that on startup, the application would hit the JWK Set endpoint, inspect the kty field of the JWKs returned, and infer the algorithm or algorithms that the decoder should support accordingly. Perhaps this could be delayed, though, until the first request comes in.

If an application wants to skip this auto-configuration, it can easily do so by specifying using NimbusJwtDecoder directly:

String jwkSetUri = "https://idp.example.org/.well-known/jwks.json";
JwtDecoder decoder = NimbusJwtDecoder.fromJwkSetUri(jwkSetUri).build();

Care will need to be taken to ensure that this change is passive. For example, NimbusJwtDecoder selects RS256 by default. For those still picking the defaults, it'd be unfortunate if the algorithms selected by reading the JWKS response didn't include RS256.

@jzheaux jzheaux added type: enhancement A general enhancement in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) labels Jul 29, 2019
@jzheaux jzheaux added this to the 5.2.0.M4 milestone Jul 29, 2019
@jzheaux jzheaux self-assigned this Jul 29, 2019
@jzheaux jzheaux modified the milestones: 5.2.0.M4, 5.2.0.RC1 Aug 5, 2019
@jzheaux jzheaux modified the milestones: 5.2.0.RC1, 5.3.x Sep 4, 2019
@mkheck
Copy link
Contributor

mkheck commented Nov 1, 2019

Hey @jzheaux, I wouldn't mind taking a run at this. Please let me know your thoughts.

@mkheck
Copy link
Contributor

mkheck commented Nov 7, 2019

Hi @jzheaux, not sure what happened to my earlier comment, but I'd like to take this on if it makes sense to you. Please let me know.

@jzheaux
Copy link
Contributor Author

jzheaux commented Nov 14, 2019

Yes, @mkheck, I think this would be a good fit. Forgive the delay - I've added some more detail to the description, which I wanted to confirm before handing it off.

@jzheaux jzheaux modified the milestones: 5.3.x, 5.4.x Jun 23, 2020
@jgrandja jgrandja modified the milestones: 5.4.x, 5.5.x Sep 9, 2020
jzheaux added a commit to jzheaux/spring-security that referenced this issue Sep 21, 2020
@jzheaux jzheaux closed this as completed in 366146f Oct 9, 2020
@jzheaux jzheaux modified the milestones: 5.5.x, 5.5.0-M1 Oct 9, 2020
@jzheaux jzheaux changed the title NimbusJwtDecoder and NimbusReactiveJwtDecoder should determine algorithm from JWK Set Endpoint JwtDecoders and ReactiveJwtDecoders should determine algorithm from JWK Set Endpoint Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants