diff --git a/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc b/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc index a8f404bf352ed2..451831db05935f 100644 --- a/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc +++ b/docs/src/main/asciidoc/security-openid-connect-multitenancy.adoc @@ -707,8 +707,9 @@ import io.quarkus.oidc.TenantResolverInterceptor; @HrTenant @Interceptor public class HrInterceptor extends TenantResolverInterceptor { - public HrInterceptor() { - super("hr"); + @Override + protected String getTenantId() { + return "hr"; } } diff --git a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/TenantResolverInterceptor.java b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/TenantResolverInterceptor.java index 05ed49b791f361..b165f133333ed4 100644 --- a/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/TenantResolverInterceptor.java +++ b/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/TenantResolverInterceptor.java @@ -10,15 +10,12 @@ public abstract class TenantResolverInterceptor { @Inject RoutingContext routingContext; - private final String tenantId; - - public TenantResolverInterceptor(String tenantId) { - this.tenantId = tenantId; - } @AroundInvoke public Object setTenant(InvocationContext context) throws Exception { - routingContext.put(OidcUtils.TENANT_ID_ATTRIBUTE, tenantId); + routingContext.put(OidcUtils.TENANT_ID_ATTRIBUTE, getTenantId()); return context.proceed(); } + + protected abstract String getTenantId(); } diff --git a/integration-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/HrInterceptor.java b/integration-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/HrInterceptor.java index a3d047b3214b19..339e6150382d04 100644 --- a/integration-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/HrInterceptor.java +++ b/integration-tests/oidc-wiremock/src/main/java/io/quarkus/it/keycloak/HrInterceptor.java @@ -7,7 +7,10 @@ @HrTenant @Interceptor public class HrInterceptor extends TenantResolverInterceptor { - public HrInterceptor() { - super("hr"); + + @Override + protected String getTenantId() { + return "hr"; } + }