Skip to content

Add JwtIssuerAuthenticationManagerResolver #7733

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

Merged
merged 1 commit into from
Jan 8, 2020

Conversation

jzheaux
Copy link
Contributor

@jzheaux jzheaux commented Dec 12, 2019

Fixes gh-7724

@jzheaux jzheaux self-assigned this Dec 12, 2019
@jzheaux jzheaux requested review from fhanik and rwinch December 12, 2019 19:01
Copy link
Contributor

@fhanik fhanik left a comment

Choose a reason for hiding this comment

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

Alright, some initial thoughts. I'm not marking it as Request Changes since we can elaborate on each

@jzheaux jzheaux force-pushed the gh-7724 branch 3 times, most recently from a9137a3 to 3a12204 Compare December 13, 2019 19:57
@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 19, 2019

@dyroberts how well would this PR address some of the concerns you raised in #5385?

With it, you could do either:

JwtAuthenticationManagerResolver authenticationManagerResolver =
        new JwtAuthenticationManagerResolver("list", "of", "issuers");

http
    .oauth2ResourceServer()
        .authenticationManagerResolver(authenticationManagerResolver)

or

Map<String, AuthenticationManager> authenticationManagers = ...;
JwtAuthenticationManagerResolver authenticationManagerResolver =
        new JwtAuthenticationManagerResolver(authenticationManagers::get);

http
    .oauth2ResourceServer()
        .authenticationManagerResolver(authenticationManagerResolver);

@dyroberts
Copy link

@jzheaux Looks really good! The only thing I could see as a slight improvement would be some auto-config to create a JwtAuthenticationManagerResolver from application properties. But maybe that's not inline with the spring-security conventions of today? Anyway, this really does cover well the case that I was referring to.

@jzheaux
Copy link
Contributor Author

jzheaux commented Dec 20, 2019

@dyroberts we are still looking into the idea of mapping this to config properties. While this does appear to be a common way to handle multi-tenancy in resource servers, it's not clear whether or not Resource Server Multi-Tenancy itself is so common as to want to add Spring Boot support.

That said, this class leaves open this possibility.

@jzheaux
Copy link
Contributor Author

jzheaux commented Jan 6, 2020

@gburboz @xsreality @bertramn How well would this PR address the concerns you raised in #6778 and #5351?

@jzheaux jzheaux changed the title Add JwtAuthenticationManagerResolver Add JwtIssuerAuthenticationManagerResolver Jan 8, 2020
@jzheaux jzheaux merged commit de87675 into spring-projects:master Jan 8, 2020
@jzheaux jzheaux deleted the gh-7724 branch January 8, 2020 06:31
@xsreality
Copy link

Hi Josh, the PR looks good. My primary concern was to be able to add/remove tenants at runtime without needing to restart the application. The updated doc makes it clear how to do that. Thanks!

@davidmelia
Copy link

@jzheaux will you be adding a reactive version of this class? Thanks

@jzheaux
Copy link
Contributor Author

jzheaux commented Jan 28, 2020

@davidmelia I think it makes sense to explore that, yes - I left a bit more detail in the ticket you raised.

@jzheaux jzheaux added this to the 5.3.0.RC1 milestone Feb 5, 2020
@jzheaux jzheaux added in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) type: enhancement A general enhancement status: duplicate A duplicate of another issue labels Feb 6, 2020
@RavindraSengar
Copy link

RavindraSengar commented Oct 13, 2020

Hi @jzheaux

I have similar use case.
One Backend API endpoint/resource
2 consumers of this BE API both will have their corresponding OAUTH2/OKTA authorization servers. Each with a different RSA key configured for creation of the JWT tokens.
In BE API, we want to accept tokens from either auth server and authenticate.
Problem - BE API/Resource is configured to use only 1 set of security.oauth2.resource.jwk.key-set-uri and security.jwt.issuer Is there a way we can mention 2 set of security.oauth2.resource.jwk.key-set-uri and security.jwt.issuer ? Or how to authenticate tokens from 2 different OKTA/OAUTH authorization servers ?

Project setup Details -

org.springframework.boot" version "2.3.1.RELEASE"
io.spring.dependency-management" version "1.0.8.RELEASE"
springSecurityVersion = "5.3.3.RELEASE"

I have gone through this support documentation but need some help to implement this.
Not sure this is right place to ask this question. but asking it anyway.
Thanks.

@jzheaux
Copy link
Contributor Author

jzheaux commented Oct 13, 2020

Thanks for reaching out, @RavindraSengar! In the future, please don't double-post as it creates noise. I've left some suggestions for you about multiple issuers over in the other ticket where you asked a similar question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: oauth2 An issue in OAuth2 modules (oauth2-core, oauth2-client, oauth2-resource-server, oauth2-jose) status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add JwtIssuerAuthenticationManagerResolver
6 participants