Skip to content
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

Resource Server - Multi-Tenant Jwt Decoder by Issuer #6817

Conversation

gburboz
Copy link

@gburboz gburboz commented Apr 25, 2019

Resolves issue #6778 : Resource Server - Multi-Tenant Jwt Decoder by Issuer

jwk-set-uri: ${mockwebserver.url}/.well-known/jwks.json
multi-tenant-jwt:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not have mock server that supports JWTs with iss claims hence have put these as sample. They need not necessarily support JWT access tokens with iss claim in it. Please suggest how to use mock JWTs here w/ iss claim

private String parseAndFindIssuer(String token) {
try {
Base64URL[] parts = JOSEObject.split(token);
JSONObject payload = JSONObjectUtils.parse(parts[1].decodeToString());
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this parsing is repeated again when NimbusJwtDecoder is invoked. If we limit this delegates to NimbusJwtDecoder and refactor the these two class we may be able to avoid double parsing.

@gburboz
Copy link
Author

gburboz commented Apr 27, 2019

Alternate approach to avoid double parsing is NimbusJwtMultiTenantDecoder.java with refactored NimbusJwtDecoder.java

Furthermore we should be able to specify validator and converter beans for respective decoder in config (either by name or type).

spring.security.oauth2.resourceserver:
  multi-tenant-jwt:
    -
      issuer-uri: "https://mockwebserver.com/"
      jwk-set-uri: ${mockwebserver.url}/.well-known/jwks.json
      converter-bean-name: "mockwebserverJwtConverter"
      validator-bean-name: "mockwebserverJwtValidator"
    -
      issuer-uri: "https://some-domain.com/"
      public-key: "${some-domain.public-key}"
      converter-bean-name: "someDomainJwtConverter"
      validator-bean-name: "someDomainJwtValidator"

@jzheaux jzheaux added the for: team-attention This ticket should be discussed as a team before proceeding label May 7, 2019
@jzheaux jzheaux removed the for: team-attention This ticket should be discussed as a team before proceeding label Jul 1, 2019
@jzheaux jzheaux self-assigned this Jul 1, 2019
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 1, 2019
@jzheaux
Copy link
Contributor

jzheaux commented Aug 17, 2019

Closing in favor of #6778 (comment) so the JWT is not parsed multiple times.

@jzheaux jzheaux closed this Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants