Skip to content

Commit 468c307

Browse files
authored
Merge pull request #48838 from sberyozkin/3.24_fix_back_channel_logout_http_root
[3.24] : Fix the http root bug in BackChannelLogoutHandler
2 parents 61d8ad2 + 48a57cb commit 468c307

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/BackChannelLogoutHandler.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import io.quarkus.oidc.SecurityEvent;
1313
import io.quarkus.oidc.SecurityEvent.Type;
14-
import io.quarkus.oidc.common.runtime.OidcCommonUtils;
1514
import io.quarkus.oidc.common.runtime.OidcConstants;
1615
import io.quarkus.security.spi.runtime.SecurityEventHelper;
1716
import io.vertx.core.Handler;
@@ -23,7 +22,6 @@
2322

2423
public class BackChannelLogoutHandler {
2524
private static final Logger LOG = Logger.getLogger(BackChannelLogoutHandler.class);
26-
private static final String SLASH = "/";
2725

2826
void setup(@Observes Router router, DefaultTenantConfigResolver resolver) {
2927
final TenantConfigBean tenantConfigBean = resolver.getTenantConfigBean();
@@ -158,18 +156,9 @@ private TenantConfigContext getTenantConfigContext(final String requestPath) {
158156
private boolean isMatchingTenant(String requestPath, TenantConfigContext tenant) {
159157
return tenant.oidcConfig().tenantEnabled()
160158
&& tenant.oidcConfig().tenantId().get().equals(oidcTenantConfig.tenantId().get())
161-
&& requestPath.equals(getRootPath() + tenant.oidcConfig().logout().backchannel().path().orElse(null));
159+
&& requestPath.equals(OidcUtils.getRootPath(resolver.getRootPath())
160+
+ tenant.oidcConfig().logout().backchannel().path().orElse(null));
162161
}
163162

164-
private String getRootPath() {
165-
// Prepend '/' if it is not present
166-
String rootPath = OidcCommonUtils.prependSlash(resolver.getRootPath());
167-
// Strip trailing '/' if the length is > 1
168-
if (rootPath.length() > 1 && rootPath.endsWith("/")) {
169-
rootPath = rootPath.substring(rootPath.length() - 1);
170-
}
171-
// if it is only '/' then return an empty value
172-
return SLASH.equals(rootPath) ? "" : rootPath;
173-
}
174163
}
175164
}

extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcUtils.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,4 +938,15 @@ public static String decryptToken(TenantConfigContext resolvedContext, String to
938938
public static boolean isDPoPScheme(String authorizationScheme) {
939939
return OidcConstants.DPOP_SCHEME.equalsIgnoreCase(authorizationScheme);
940940
}
941+
942+
public static String getRootPath(String configuredRootPath) {
943+
// Prepend '/' if it is not present
944+
String rootPath = OidcCommonUtils.prependSlash(configuredRootPath);
945+
// Strip trailing '/' if the length is > 1
946+
if (rootPath.length() > 1 && rootPath.endsWith("/")) {
947+
rootPath = rootPath.substring(0, rootPath.length() - 1);
948+
}
949+
// if it is only '/' then return an empty value
950+
return "/".equals(rootPath) ? "" : rootPath;
951+
}
941952
}

extensions/oidc/runtime/src/test/java/io/quarkus/oidc/runtime/OidcUtilsTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333

3434
public class OidcUtilsTest {
3535

36+
@Test
37+
public void getRoorPath() throws Exception {
38+
39+
assertEquals("", OidcUtils.getRootPath("/"));
40+
assertEquals("/root", OidcUtils.getRootPath("/root"));
41+
assertEquals("/root", OidcUtils.getRootPath("root"));
42+
assertEquals("/root", OidcUtils.getRootPath("/root/"));
43+
}
44+
3645
@Test
3746
public void testDpopScheme() throws Exception {
3847

0 commit comments

Comments
 (0)