Skip to content

Nimbus Jwt Decoder Configurability #5648

Closed
@jzheaux

Description

@jzheaux

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:

  1. Write tests that do not depend on a legitimate static Jwt and Jwk Set to be provided, simplifying unit tests
  2. Provide for easier configuration for users who want to configure Nimbus themselves outside of Spring Security's guidance.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions