Use the Keycloak server URL for common resources (#30823)

Closes #30541

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2024-06-26 16:52:25 +02:00 committed by GitHub
parent 261bc41af2
commit cd0dbdf264
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -96,15 +96,9 @@ public class AccountConsole implements AccountResourceProvider {
@NoCache
@Path("{any:.*}")
public Response getMainPage() throws IOException, FreeMarkerException {
// Get the URI info of the server and admin console.
final var serverUriInfo = session.getContext().getUri(UrlType.FRONTEND);
final var adminUriInfo = session.getContext().getUri(UrlType.ADMIN);
// Get the base URLs of the server and admin console.
final var serverBaseUri = serverUriInfo.getBaseUri();
final var adminBaseUri = adminUriInfo.getBaseUri();
// Strip any trailing slashes from the URLs.
// Strip any trailing slashes from the URL.
final var serverBaseUrl = serverBaseUri.toString().replaceFirst("/+$", "");
final var map = new HashMap<String, Object>();
@ -124,7 +118,7 @@ public class AccountConsole implements AccountResourceProvider {
map.put("realm", realm);
map.put("clientId", Constants.ACCOUNT_CONSOLE_CLIENT_ID);
map.put("resourceUrl", Urls.themeRoot(serverBaseUri).getPath() + "/" + Constants.ACCOUNT_MANAGEMENT_CLIENT_ID + "/" + theme.getName());
map.put("resourceCommonUrl", Urls.themeRoot(adminBaseUri).getPath() + "/common/keycloak");
map.put("resourceCommonUrl", Urls.themeRoot(serverBaseUri).getPath() + "/common/keycloak");
map.put("resourceVersion", Version.RESOURCES_VERSION);
String[] referrer = getReferrer();