-
Notifications
You must be signed in to change notification settings - Fork 41.1k
Support multiple JWT issuer-uris #30108
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
Comments
spring.security.oauth2.resourceserver.jwt.issuer-uri
into a String[]spring.security.oauth2.resourceserver.jwt.issuer-uri
into a String[]
spring.security.oauth2.resourceserver.jwt.issuer-uri
into a String[]
spring.security.oauth2.resourceserver.jwt.issuer-uri
into an array
spring.security.oauth2.resourceserver.jwt.issuer-uri
into an array
I (we as a team) would like to take this up |
Is this issue available? I would like to try to do this |
https://spring.io/blog/2022/06/01/spring-security-oauth-reaches-end-of-life I suggest you get a look at alternatives for spring-boot resource-servers auto-configuration. Maybe this one I wrote ? |
@ch4mpy Spring Security itself provides OAuth support these days and Spring Boot provides auto-configuration for it. IMO, there's no need to look for an alternative. |
@EduColnago thanks for the offer but we're not quite sure how to handle this one yet. Please watch the ideal-for-contribution label. |
Given the Spring Security team's position on multiple issuer URIs and their decision to decline spring-projects/spring-security#10943, I'm not sure that we should do anything in Spring Boot. IMO, it does not make sense to allow multiple URIs to be configured when Spring Boot's auto-configuration will only use one of them. This wouldn't address the confusion described in the description above, it would just change its source. I also don't think it makes sense for Spring Boot to support multiple issuer URIs if that requires us to maintain a composite Flagging for team attention to see what everyone else thinks. /cc @jzheaux |
@wilkinsona I had read the blog post too fast. My bad. But, actually I can find some reasons to look for alternatives to OpenID resource-server auto-configuration with
This are not just speculations, it is possible to achieve all of above with just a few properties: I do it there @SpringBootApplication
public class ResourceServerWithOAuthenticationApplication {
public static void main(String[] args) {
SpringApplication.run(ResourceServerWithOAuthenticationApplication.class, args);
}
@EnableGlobalMethodSecurity(prePostEnabled = true)
public static class WebSecurityConfig {
}
} and that config # shoud be set to where your authorization-server is
com.c4-soft.springaddons.security.token-issuers[0].location=https://localhost:9443/auth/realms/master
# shoud be configured with a list of private-claims this authorization-server puts user roles into
# below is default Keycloak conf for a `spring-addons` client with client roles mapper enabled
com.c4-soft.springaddons.security.token-issuers[0].authorities.claims=realm_access.roles,resource_access.spring-addons.roles
com.c4-soft.springaddons.security.cors[0].path=/greet/**
com.c4-soft.springaddons.security.permit-all=/actuator/health/readiness,/actuator/health/liveness,/v3/api-docs/**
# use IDE auto-completion or see SpringAddonsSecurityProperties javadoc for complete configuration properties list Bootyful, isn't it? As you could guess from
I do it with JwtIssuerAuthenticationManagerResolver or ReactiveAuthenticationManagerResolver (credits go to spring-security team who told me that it is the expected way to do it, in the ticket you linked) |
@ch4mpy is correct that Spring Security ships with a component that supports multiple issuer URIs, primarily to support multi-tenant applications. Hypothetically, Boot could publish a This would have wider-reaching consequences than simply allowing Note that the reason the OAuth2 Client properties allow for declaring more than one client is to support multiple identity providers, like Google and Facebook. The fact that they can be used for multi-tenancy is a nice additional benefit, but not the primary use case. c4soft chooses a multi-tenant approach and I appreciate the fact that there is an open-source solution out there based on Spring Security's resource server that enables this for those who need it. By the way, @ch4mpy, I appreciate the list of features you generated above, that's really helpful. You and I have discussed some of those already, and I'd welcome further collaboration to find what's a good fit for adding to Spring Security. |
Thanks @jzheaux. Given the comments above I don't think we should try to support multiple JWT issuer URIs. Thanks anyway for the suggestion and thanks for open-sourcing your springaddons project. |
@jzheaux @philwebb how is the spring-boot app serving resources to such clients supposed to handle end-users identity with a single configured authorization-server in that case? Should it choose Google or Facebook?
Those features are mostly configuration of existing spring-security elements, reason for me listing it here in spring-boot. There are only two things I use which are not from spring-security:
Do not easitate to open tickets on https://github.com/ch4mpy/spring-addons if you find something useful for the comunity, I'll do my best to help you migrate corresponding code from this repo to spring-security or spring-boot ones. |
Neither. Google's token is for protecting Google's resource servers. Or, IOW, if the resources being served are on Google resource servers, then you would use Google's token. |
Only? https://developers.google.com/identity/sign-in/web/backend-auth Beyond what Google offers as OAuth2 authentication, there are online OIDC providers out there which allow to define audience(s). I have quite a few (dozens) resource-servers at hand that have to accept various issuers either because
|
Google's documentation refers to flowing the user's identity to a server, not to authorizing a client's request for resources protected by that server. If you haven't already, please see the link I posted in my previous comment. I also feel like the maintainers' comments in this thread are a good representation of my position. That said, we might be getting off-topic discussing how various providers interpret the spec. The resource server arrangements you describe sound like classic multi-tenancy examples. I feel I already stated my position on changing Boot's properties from being single-tenant to multi-tenant, and I've got nothing more to add. Should multi-tenant resource servers become quite common, we can always take another look. |
spring-projects/spring-security#8648 (comment) mostly solved my issue with having multi tenant issuers |
Enhancement:
spring.security.oauth2.resourceserver.jwt.issuer-uri
configuration property currently accepts a single value.In some cases (like multi-tenant environments), resource-servers accept identities issued by more than just one authorization-server.
It would ease spring-boot apps security configuration if
spring.security.oauth2.resourceserver.jwt.issuer-uri
could accept an array of issuers.Currently I have to use a private property for that purpose and that leads to quite some confusion for developers used to spring-boot one.
Notes:
String
toString[]
) without breaking existing config filesThe text was updated successfully, but these errors were encountered: