-
Notifications
You must be signed in to change notification settings - Fork 6k
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
JwkSourceReactiveJwtDecoderBuilder should be typed SignedJWT instead of JWT #6771
Comments
Agreed that it should be This implementation addresses #6367 and is intended to simplify the construction of a With traditional Nimbus, the user can customize key retreival like so: JWKSource<SecurityContext> jwkSource = // use a Nimbus implementation or customize
JWSKeySelector<SecurityContext> jwsKeySelector =
new JWSVerificationKeySelector<>(jwsAlgorithm, jwkSource);
DefaultJWTProcessor<SecurityContext> jwtProcessor = new DefaultJWTProcessor<>();
jwtProcessor.setJWSKeySelector(jwsKeySelector);
NimbusJwtDecoder jwtDecoder = new NimbusJwtDecoder(jwtProcessor); However, with reactive, it's quite a bit more roundabout, using the Nimbus API in a counter-intuitive way: Function<SignedJWT, Flux<JWK>> reactiveJwkSource = // get the keys reactively
JWKSecurityContextJWKSet jwkSource = new JWKSecurityContextJWKSet();
JWSKeySelector<JWKSecurityContext> jwsKeySelector =
new JWSVerificationKeySelector<>(this.jwsAlgorithm, jwkSource);
DefaultJWTProcessor<JWKSecurityContext> jwtProcessor = new DefaultJWTProcessor<>();
jwtProcessor.setJWSKeySelector(jwsKeySelector);
Converter<SignedJWT, Mono<JWTClaimSet>> reactiveJwtProcessor = signedJWT ->
reactiveJwkSource.apply(signedJWT)
.collectList()
.map(jwks -> createClaimSet(jwtProcessor, signedJWT, new JWKSecurityContext(jwks)));
NimbusReactiveJwtDecoder jwtDecoder = new NimbusReactiveJwtDecoder(reactiveJwtProcessor); I believe it would be challenging and cumbersome for the user to configure the decoder in this way. So, they can instead do: Function<SignedJWT, Flux<JWK>> reactiveJwkSource = // get the keys reactively
NimbusReactiveJwtDecoder jwtDecoder = NimbusReactiveJwtDecoder
.withJwkSource(reactiveJwkSource).build(); Since the primary configuration of a Of course, we could add For some extra context, the original impetus was from some requirements outlined by @GregoireW. If you are agreed that we should keep it and simply change the parameter type from |
Thanks for the explanation @jzheaux. This makes sense. We only need to change |
Hello Thank you |
@alurysharad, no, are you interested in submitting a PR for it? |
Yes |
Changed the parameter type from JWT to SignedJWT Fixes: gh-6771
We should consider removing
NimbusReactiveJwtDecoder.JwkSourceReactiveJwtDecoderBuilder
since it's not used.I also noticed that the equivalent does not exist in
NimbusJwtDecoder
.If we decide to keep it than we should change the generic types from
Function<JWT, Flux<JWK>>
toFunction<SignedJWT, Flux<JWK>>
.The text was updated successfully, but these errors were encountered: