Skip to content

Support for setting different 'jwk-set-uri's for each JWT in OAuth 2.0 Resource Server Multi-tenancy #13808

Closed
@sgc109

Description

@sgc109

Expected Behavior
I thought it can't be better if I can just list sets of information for each JWT format(issuer, jwk-set-uri, ...) in application.yaml like below(It's just an example. So it might not be compatible with another configurations of Spring Security OAuth2).

spring:
  security:
    oauth2:
      resourceservers:
        server1: # it'd be just a name developers designate
          jwt:
            jwk-set-uri: original.jwks.server:8080/.well-known/jwks.json
            issuer-uri: https://s1.host.name
        server2:
          jwt:
            jwk-set-uri: new.jwks.server:8080/.well-known/jwks.json
            issuer-uri: https://s2.host.name

But, I found that these kind of configuration is not possible at the moment.

If support like above is not easy right now, it'd be really nice if I can configure different 'jwk-set-uri's for each issuer with using JwtIssuerReactiveAuthenticationManagerResolver.
According to documentation of it, I can just set multiple issuers, but not able to set different jwt-set-uris.

JwtIssuerReactiveAuthenticationManagerResolver authenticationManagerResolver = new JwtIssuerReactiveAuthenticationManagerResolver
    ("https://idp.example.org/issuerOne", "https://idp.example.org/issuerTwo");

http
    .authorizeExchange(exchanges -> exchanges
        .anyExchange().authenticated()
    )
    .oauth2ResourceServer(oauth2 -> oauth2
        .authenticationManagerResolver(authenticationManagerResolver)
    );

Current Behavior
Just support one set of jwk-set-uri and issuer like below.

spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: original.server:8080/.well-known/jwks.json
          issuer-uri: https://s1.host.name

And can't configure multiple jwk-set-uris associating with multiple issuers with using JwtIssuerReactiveAuthenticationManagerResolver, which is for OAuth2 resource server multi-tenancy.

Context
Let me explain about my situation.
Our service is using JWT in Resource Server issued by an Authorization Server(Let's call it S1).
Also, we should have specific jwk-set-uri which is separated from issuer.
application.yaml is like below.

spring:
  security:
    oauth2:
      resourceserver:
        jwt:
          jwk-set-uri: original.server:8080/.well-known/jwks.json
          issuer-uri: https://s1.host.name

Now we are replacing original Authorization Server(S1) to new one(S2) for issuing.
And new issuer also has its own jwk-set-uri.
In order for backward compatibility, we should permit original JWT format(issuer & jwk-set-uri) and, at the same time, new JWT format.

Metadata

Metadata

Assignees

Labels

in: oauth2An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose)status: duplicateA duplicate of another issuetype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions