13
13
import io .quarkus .oidc .OidcTenantConfig ;
14
14
import io .quarkus .oidc .SecurityEvent ;
15
15
import io .quarkus .oidc .SecurityEvent .Type ;
16
+ import io .quarkus .oidc .common .runtime .OidcCommonUtils ;
16
17
import io .quarkus .oidc .common .runtime .OidcConstants ;
17
18
import io .quarkus .security .spi .runtime .SecurityEventHelper ;
18
19
import io .vertx .core .Handler ;
24
25
25
26
public class BackChannelLogoutHandler {
26
27
private static final Logger LOG = Logger .getLogger (BackChannelLogoutHandler .class );
28
+ private static final String SLASH = "/" ;
27
29
28
30
@ Inject
29
31
DefaultTenantConfigResolver resolver ;
@@ -44,7 +46,8 @@ public void setup(@Observes Router router) {
44
46
45
47
private void addRoute (Router router , OidcTenantConfig oidcTenantConfig ) {
46
48
if (oidcTenantConfig .isTenantEnabled () && oidcTenantConfig .logout .backchannel .path .isPresent ()) {
47
- router .route (oidcTenantConfig .logout .backchannel .path .get ()).handler (new RouteHandler (oidcTenantConfig ));
49
+ router .route (getRootPath () + oidcTenantConfig .logout .backchannel .path .get ())
50
+ .handler (new RouteHandler (oidcTenantConfig ));
48
51
}
49
52
}
50
53
@@ -160,7 +163,18 @@ private TenantConfigContext getTenantConfigContext(RoutingContext context) {
160
163
private boolean isMatchingTenant (String requestPath , TenantConfigContext tenant ) {
161
164
return tenant .oidcConfig .isTenantEnabled ()
162
165
&& tenant .oidcConfig .getTenantId ().get ().equals (oidcTenantConfig .getTenantId ().get ())
163
- && requestPath .equals (tenant .oidcConfig .logout .backchannel .path .orElse (null ));
166
+ && requestPath .equals (getRootPath () + tenant .oidcConfig .logout .backchannel .path .orElse (null ));
164
167
}
165
168
}
169
+
170
+ private String getRootPath () {
171
+ // Prepend '/' if it is not present
172
+ String rootPath = OidcCommonUtils .prependSlash (resolver .getRootPath ());
173
+ // Strip trailing '/' if the length is > 1
174
+ if (rootPath .length () > 1 && rootPath .endsWith ("/" )) {
175
+ rootPath = rootPath .substring (rootPath .length () - 1 );
176
+ }
177
+ // if it is only '/' then return an empty value
178
+ return SLASH .equals (rootPath ) ? "" : rootPath ;
179
+ }
166
180
}
0 commit comments