Skip to content

Commit

Permalink
Add http root to OIDC back channel logout handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Aug 13, 2024
1 parent 64f0196 commit 746f10a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

public class BackChannelLogoutHandler {
private static final Logger LOG = Logger.getLogger(BackChannelLogoutHandler.class);
private static final String SLASH = "/";

@Inject
DefaultTenantConfigResolver resolver;
Expand All @@ -44,7 +45,8 @@ public void setup(@Observes Router router) {

private void addRoute(Router router, OidcTenantConfig oidcTenantConfig) {
if (oidcTenantConfig.isTenantEnabled() && oidcTenantConfig.logout.backchannel.path.isPresent()) {
router.route(oidcTenantConfig.logout.backchannel.path.get()).handler(new RouteHandler(oidcTenantConfig));
router.route(getRootPath() + oidcTenantConfig.logout.backchannel.path.get())
.handler(new RouteHandler(oidcTenantConfig));
}
}

Expand Down Expand Up @@ -160,7 +162,12 @@ private TenantConfigContext getTenantConfigContext(RoutingContext context) {
private boolean isMatchingTenant(String requestPath, TenantConfigContext tenant) {
return tenant.oidcConfig.isTenantEnabled()
&& tenant.oidcConfig.getTenantId().get().equals(oidcTenantConfig.getTenantId().get())
&& requestPath.equals(tenant.oidcConfig.logout.backchannel.path.orElse(null));
&& requestPath.equals(getRootPath() + tenant.oidcConfig.logout.backchannel.path.orElse(null));
}
}

private String getRootPath() {
final String rootPath = resolver.getRootPath();
return SLASH.equals(rootPath) ? "" : rootPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public class DefaultTenantConfigResolver {
private final TenantConfigBean tenantConfigBean;
private final TenantResolver[] staticTenantResolvers;
private final boolean annotationBasedTenantResolutionEnabled;
private final String rootPath;

@Inject
Instance<TenantConfigResolver> tenantConfigResolver;
Expand Down Expand Up @@ -86,6 +87,7 @@ public class DefaultTenantConfigResolver {
this.staticTenantResolvers = prepareStaticTenantResolvers(tenantConfigBean, rootPath, tenantResolverInstance,
resolveTenantsWithIssuer, new DefaultStaticTenantResolver());
this.annotationBasedTenantResolutionEnabled = Boolean.getBoolean(OidcUtils.ANNOTATION_BASED_TENANT_RESOLUTION_ENABLED);
this.rootPath = rootPath;
}

@PostConstruct
Expand Down Expand Up @@ -414,6 +416,10 @@ public OidcTenantConfig getResolvedConfig(String sessionTenantId) {
return null;
}

public String getRootPath() {
return rootPath;
}

private static final class IssuerBasedTenantResolver implements TenantResolver {

private final TenantConfigContext[] tenantConfigContexts;
Expand Down

0 comments on commit 746f10a

Please sign in to comment.