Skip to content

Commit b049e55

Browse files
authored
Merge pull request #48851 from jmartisk/3.20.2-backports-6
[3.20] 3.20.2 backports 6
2 parents 99c4db2 + 66c72f5 commit b049e55

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed

.mvn/extensions.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<extension>
1818
<groupId>io.quarkus.develocity</groupId>
1919
<artifactId>quarkus-project-develocity-extension</artifactId>
20-
<version>1.2.2</version>
20+
<version>1.2.3</version>
2121
</extension>
2222
<extension>
2323
<groupId>eu.maveniverse.maven.njord</groupId>

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
@@ -846,4 +846,15 @@ public static boolean isApplicationJwtContentType(String ct) {
846846
public static boolean isDPoPScheme(String authorizationScheme) {
847847
return OidcConstants.DPOP_SCHEME.equalsIgnoreCase(authorizationScheme);
848848
}
849+
850+
public static String getRootPath(String configuredRootPath) {
851+
// Prepend '/' if it is not present
852+
String rootPath = OidcCommonUtils.prependSlash(configuredRootPath);
853+
// Strip trailing '/' if the length is > 1
854+
if (rootPath.length() > 1 && rootPath.endsWith("/")) {
855+
rootPath = rootPath.substring(0, rootPath.length() - 1);
856+
}
857+
// if it is only '/' then return an empty value
858+
return "/".equals(rootPath) ? "" : rootPath;
859+
}
849860
}

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)