Skip to content

Commit

Permalink
[ELY-2034] Sanitize the provider-url in case a trailing slash was spe…
Browse files Browse the repository at this point in the history
…cified
  • Loading branch information
fjuma committed Sep 10, 2021
1 parent 818dfaf commit 98450ce
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.wildfly.security.http.oidc;

import static org.wildfly.security.http.oidc.ElytronMessages.log;
import static org.wildfly.security.http.oidc.Oidc.SLASH;
import static org.wildfly.security.http.oidc.Oidc.SSLRequired;
import static org.wildfly.security.http.oidc.Oidc.TokenStore;

Expand Down Expand Up @@ -145,14 +146,21 @@ protected OidcClientConfiguration internalBuild(final OidcJsonConfiguration oidc
}
oidcClientConfiguration.setClient(createHttpClientProducer(oidcJsonConfiguration));
oidcClientConfiguration.setAuthServerBaseUrl(oidcJsonConfiguration);
oidcClientConfiguration.setProviderUrl(oidcJsonConfiguration.getProviderUrl());
oidcClientConfiguration.setProviderUrl(sanitizeProviderUrl(oidcJsonConfiguration.getProviderUrl()));
if (oidcJsonConfiguration.getTurnOffChangeSessionIdOnLogin() != null) {
oidcClientConfiguration.setTurnOffChangeSessionIdOnLogin(oidcJsonConfiguration.getTurnOffChangeSessionIdOnLogin());
}

return oidcClientConfiguration;
}

private static String sanitizeProviderUrl(String providerUrl) {
if (providerUrl != null && providerUrl.endsWith(SLASH)) {
return providerUrl.substring(0, providerUrl.length() - 1);
}
return providerUrl;
}

private Callable<HttpClient> createHttpClientProducer(final OidcJsonConfiguration oidcJsonConfiguration) {
return new Callable<HttpClient>() {
private HttpClient client;
Expand Down

0 comments on commit 98450ce

Please sign in to comment.