-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Simplify tenant resolution for the OIDC/Hibernate Multitenancy combination #11949
Comments
We should avoid creating a direct dependency to the vertx extension by using the |
@michael-schnell Right, in the OIDC code we do need |
This shouldn't be something specific to either OIDC or Hibernate. It should be a neutral aspect of the Quarkus environment, by which I mean that there should be an agreed place where tenant ids are made available by some extensions, and consumed by others. It shouldn't be a matter of OIDC and Hibernate agreeing on some sort of protocol, but rather the Quarkus environment providing a standard place where the tenant id set. |
@gavinking I just switched off my laptop and then on again to close this issue :-), because I realized a custom user OIDC resolver can pass it as a routing context attribute over a custom user Hibernate resolver, so it is entirely up to the users if they would want it or not and Quarkus does not need to do anything itself (at least on the OIDC + Hibernate multi-tenancy path). |
I think it is still worth thinking about harmonizing the TenantResolver for ODIC and DataSource (currently Hibernate ORM). This would allow other extensions to use the same information. But the TenantResolver interface itself should be independent of other extensions. I guess it shoudl be possible to adjust the current ODIC TenantResolver in a way that is backward compatible, but still uses the new interface. |
Hi @michael-schnell I'm not sure there is much scope in it, we'd need to introduce some But what would concern me more with respect to focusing on a single interface is that the tenant concept may have a different granularity in OIDC and Data cases. |
I guess the 90% use case is exactly what you described:
You must ensure that any user is authorized for a realm/tenant to access the database and possibly other resources. Another scenario is for example a batch process that executes some kind of updates for all tenants:
For that use case you will not have a RoutingContext and can implicitly assume that the batch process is authorized to access all tenants. You will need to set the tenant in in the context directly, simply by using the tenant id from the list query. So you have two parts:
|
@michael-schnell great, thanks for this overview. I can keep this open if you'd like but I do feel that just doing
is enough for such cases when both OIDC and Hibernate resolvers need to get the id from the HTTP request. |
Description
Tenant id has to be resolved to support both OIDC and Hibernate multi-tenancy flows.
In both cases a tenant id can be extracted from
RoutingContext
, for example, see OIDC and Hibernate resolver examples.Effectively a user needs to write nearly the same code twice to get a tenant id out of
RoutingContext
.Implementation ideas
OIDC security always runs first, hence a simple proposal is:
RoutingContext
tenant-id
attributeio.quarkus.hibernate.orm.runtime.tenant.TenantResolver
. If it is not available then it picks up this currenttenant-id
RoutingContext
attribute if an OIDC-neutral property likequarkus.hibernate.use-context-tenant-id=true
The end result is that Hibernate users will benefit, they won't have to write their own resolver id when the OIDC and Hibernate tenant resolution logic is the same :-)
See also the related discussion at #11861.
Hi @gsmet @Sanne @FroMage @gavinking - if you are also OK with it then I'll open a PR making an OIDC related update (save the OIDC tenant id as a
RoutingContext
attribute). And a related Hibernate (etc) enhancement can follow ?The text was updated successfully, but these errors were encountered: