Skip to content

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

Closed
@gburboz

Description

@gburboz

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.com

OR

security.oauth2.resourceserver:
  jwt:
    jwks_url: https://idp.example.com

Expected 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.com

The 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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions