KEYCLOAK-16798 Add guarding condition for multi-thread usage in KeycloakDeployment.java
This commit is contained in:
parent
ba8e2fef6b
commit
1c445cc4cc
1 changed files with 25 additions and 16 deletions
|
@ -170,27 +170,36 @@ public class KeycloakDeployment {
|
||||||
protected void resolveUrls() {
|
protected void resolveUrls() {
|
||||||
if (realmInfoUrl == null) {
|
if (realmInfoUrl == null) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
KeycloakUriBuilder authUrlBuilder = KeycloakUriBuilder.fromUri(authServerBaseUrl);
|
if (realmInfoUrl == null) {
|
||||||
|
KeycloakUriBuilder authUrlBuilder = KeycloakUriBuilder
|
||||||
|
.fromUri(authServerBaseUrl);
|
||||||
|
|
||||||
String discoveryUrl = authUrlBuilder.clone().path(ServiceUrlConstants.DISCOVERY_URL).build(getRealm()).toString();
|
String discoveryUrl = authUrlBuilder.clone()
|
||||||
try {
|
.path(ServiceUrlConstants.DISCOVERY_URL).build(getRealm()).toString();
|
||||||
log.debugv("Resolving URLs from {0}", discoveryUrl);
|
try {
|
||||||
|
log.debugv("Resolving URLs from {0}", discoveryUrl);
|
||||||
|
|
||||||
OIDCConfigurationRepresentation config = getOidcConfiguration(discoveryUrl);
|
OIDCConfigurationRepresentation config = getOidcConfiguration(discoveryUrl);
|
||||||
|
|
||||||
authUrl = KeycloakUriBuilder.fromUri(config.getAuthorizationEndpoint());
|
authUrl = KeycloakUriBuilder.fromUri(config.getAuthorizationEndpoint());
|
||||||
realmInfoUrl = config.getIssuer();
|
realmInfoUrl = config.getIssuer();
|
||||||
|
|
||||||
tokenUrl = config.getTokenEndpoint();
|
tokenUrl = config.getTokenEndpoint();
|
||||||
logoutUrl = KeycloakUriBuilder.fromUri(config.getLogoutEndpoint());
|
logoutUrl = KeycloakUriBuilder.fromUri(config.getLogoutEndpoint());
|
||||||
accountUrl = KeycloakUriBuilder.fromUri(config.getIssuer()).path("/account").build().toString();
|
accountUrl = KeycloakUriBuilder.fromUri(config.getIssuer()).path("/account")
|
||||||
registerNodeUrl = authUrlBuilder.clone().path(ServiceUrlConstants.CLIENTS_MANAGEMENT_REGISTER_NODE_PATH).build(getRealm()).toString();
|
.build().toString();
|
||||||
unregisterNodeUrl = authUrlBuilder.clone().path(ServiceUrlConstants.CLIENTS_MANAGEMENT_UNREGISTER_NODE_PATH).build(getRealm()).toString();
|
registerNodeUrl = authUrlBuilder.clone()
|
||||||
jwksUrl = config.getJwksUri();
|
.path(ServiceUrlConstants.CLIENTS_MANAGEMENT_REGISTER_NODE_PATH)
|
||||||
|
.build(getRealm()).toString();
|
||||||
|
unregisterNodeUrl = authUrlBuilder.clone()
|
||||||
|
.path(ServiceUrlConstants.CLIENTS_MANAGEMENT_UNREGISTER_NODE_PATH)
|
||||||
|
.build(getRealm()).toString();
|
||||||
|
jwksUrl = config.getJwksUri();
|
||||||
|
|
||||||
log.infov("Loaded URLs from {0}", discoveryUrl);
|
log.infov("Loaded URLs from {0}", discoveryUrl);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warnv(e, "Failed to load URLs from {0}", discoveryUrl);
|
log.warnv(e, "Failed to load URLs from {0}", discoveryUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue