-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Description
Summary
This is related to Issue #5351 but takes different approach to support multi-tenant Jwt Decoders by issuer
Actual Behavior
Currently Resource Server with jwt is configured as shown below which is then configured with underlying NimbusJwtDecoder to decode tokens.
security.oauth2.resourceserver:
jwt:
issuer-uri: https://idp.example.comOR
security.oauth2.resourceserver:
jwt:
jwks_url: https://idp.example.comExpected Behavior
Proposal is to add MultiTenantDelegatingJwtDecoder which is composed of multiple NimbusJwtDecoder indexed by a mandatory issuer-uri (Map<URL, NimbusJwtDecoder>) .
Use following configuration:
security.oauth2.resourceserver:
multi-tenant-jwt:
-
jwt:
issuer-uri: https://idp.example.com
jwks_url: https://idp.example.com
-
jwt:
issuer-uri: https://idp-other.example.com
jwks_url: https://idp-other.example.comThe multi tenant decoder does initial parsing (JWT jwt = parse(token);) and lookup the issuer claim from parsed JWT.
Based off issuer claim, it will look up underlying NimbusJwtDecoder and delegates further processing to it.
NimbusJwtDecoder can optionally be modified so that it will have additional Jwt decode(JWT token) to avoid double parsing (JWT jwt = parse(token);).
Version
Spring Security 5.1.x
Sample
If NimbusJwtDecoder is not to be modified, MultiTenantDelegatingJwtDecoder can be implemented with pull request #6779