OIDC with KeyCloak multi-tenant setup. #52844
Unanswered
mustafamotiwala
asked this question in
Q&A
Replies: 2 comments 4 replies
-
|
/cc @sberyozkin (keycloak,oidc) |
Beta Was this translation helpful? Give feedback.
4 replies
-
|
Quarkus OIDC has built-in multi-tenant support. The key is implementing a Here's the pattern: @ApplicationScoped
public class CustomTenantConfigResolver implements TenantConfigResolver {
@Override
public Uni<OidcTenantConfig> resolve(RoutingContext context, OidcRequestContext<OidcTenantConfig> requestContext) {
String tenantId = extractTenantId(context); // from path, header, or subdomain
OidcTenantConfig config = new OidcTenantConfig();
config.setTenantId(tenantId);
config.setAuthServerUrl("https://keycloak.example.com/realms/" + tenantId);
config.setClientId("my-app");
config.setApplicationType(OidcTenantConfig.ApplicationType.SERVICE);
return Uni.createFrom().item(config);
}
private String extractTenantId(RoutingContext context) {
// Option 1: From path parameter
// e.g., /api/{tenant}/resource
return context.pathParam("tenant");
// Option 2: From header
// return context.request().getHeader("X-Tenant-ID");
}
}Important notes:
See the Quarkus OIDC Multi-Tenancy guide for the full documentation. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to configure my application with OIDC. In our setup, each tenant in KeyCloak is configured in their own realm.
In my quarkus app, I have implemented a
TenantConfigResolverwhich dynamically resolves the issuer to validate that the base URL matches. However, when I try to launch the app, I get an error aboutquarkus.oidc.auth-server-urlnot set. When I set thequarkus.oidc.auth-server-urlto the base URL for my key-cloak server, the app fails to start because the OIDC endpoints don't work.What might I be doing wrong? How should I go about doing this? My end-goal is to allow the OAuth2 authentication to work & validate JWT tokens using OIDC - provided the issuer base URL matches our KeyCloak instance.
Beta Was this translation helpful? Give feedback.
All reactions