-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Multi-tenancy support for OAuth2 #5351
Comments
We indeed had the requirement to run a single resource server that can validate JWTs issued by multiple issuers. We had to implement our own given the Spring one does not support this and Keycloak adapters only support Keycloak specific issuers. We had 2 main use cases for multi tenancy:
This use case requires the IssuerResolver to lookup (and cache) issuer metadata JWKS certs.
This use case requires a pre-configured IssuerResolver which is configured with the issuer (iss) name it supports and then either the metadata url or the public cert, where the later does not really work well if your issuer performs key rotation. Another interesting aspect we ran into was that if we just want to run a API based resource server (ie. Spring Boot micro service) there will be a lot of unnecessary moving parts in the Spring Security configuration. We ended up implementing 3 components (AccessDeniedHandler, AuthenticationFailureHandler and AuthenticationEntryPoint), everything else is surplus and massively overcomplicates things. |
Related #5385 |
In a multi-tenant configuration, each tenant would likely come with its own set of allowed issuers. A tenant-specific request would trust only a subset of the issuers configured for the resource server. We would need to introduce a selection mechanism to pick the allowed issuer(s) for a request. This For example, the |
@jzheaux since this is released with spring security 5.2.0 is there any documentation or example to follow ? (Not only for resource server but oauth2 clients included) |
@canayozel Multi-tenancy support for clients is had through multiple client registrations: https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#oauth2login-custom-provider-properties For resource server, we have a sample, but are still on the hook for adding documentation. |
Hmm not too sure how the multi tenant example is of use to anyone wanting to run a Resource Server that can validate JWTs from different issuers. It just flip-flops the |
@bertramn, you are right that 5.2.x doesn't support any specific multi-tenancy model for resource servers. #7724 demonstrates one way Spring Security might be able to support your use case for JWTs and multiple issuers - feel free to comment over there how well that implementation simplifies your customizations. |
Thanks a lot for this video https://www.youtube.com/watch?v=ke13w8nab-k |
Summary
Today, it isn't clear how to best configure Spring Security to support a multi-tenant OAuth2 client.
Here is an example of one approach out in the wild:
https://github.com/thomasdarimont/spring-boot-2-keycloak-oauth-example/blob/feature/mulit-tenancy/src/main/java/demo/SpringBoot2App.java#L127
Though whether
JwtDecoder
is the ideal place and how tenants might possibly be treated in a more first-class way is yet to be seen. Opening this issue to get the conversation started.The text was updated successfully, but these errors were encountered: