Closed
Description
It would be nice if NimbusJwtDecoderJwkSupport
were a bit easier to test. Also, NimbusJwtDecoderJwkSupport
is very opinionated in the way that Nimbus gets configured.
We could alleviate both of these by introducing a constructor or separate JwtDecoder
implementation entirely that takes a Nimbus JwtProcessor
:
public NimbusJwtDecoderJwkSupport(JwtProcessor<SecurityContext> jwtProcessor) {
this.jwtProcessor = jwtProcessor;
}
or
public class NimbusJwtDecoder(JwtProcessor<SecurityContext> jwtProcessor) {
this.jwtProcessor = this.jwtProcessor;
}
// and
private NimbusJwtDecoder delegate;
public class NimbusJwtDecoderJwkSupport(String jwkSetUrl) {
JwtProcessor<SecurityContext> jwtProcessor = // .... configure
this.delegate = new NimbusJwtDecoder(jwtProcessor);
}
Either of these would make it possible to:
- Write tests that do not depend on a legitimate static Jwt and Jwk Set to be provided, simplifying unit tests
- Provide for easier configuration for users who want to configure Nimbus themselves outside of Spring Security's guidance.