KEYCLOAK-4737 Admin Console redirect loop when hostname contains console

This commit is contained in:
Stian Thorgersen 2017-04-19 14:43:56 +02:00
parent e54c1d7de1
commit 0a0d2174e4
3 changed files with 5 additions and 8 deletions

View file

@ -296,6 +296,7 @@ public class AdminConsole {
authUrl = authUrl.substring(0, authUrl.length() - 1);
map.put("authUrl", authUrl);
map.put("consoleBaseUrl", uriInfo.getRequestUri().toString());
map.put("resourceUrl", Urls.themeRoot(baseUri) + "/admin/" + theme.getName());
map.put("masterRealm", Config.getAdminRealm());
map.put("resourceVersion", Version.RESOURCES_VERSION);

View file

@ -17,6 +17,7 @@
<script type="text/javascript">
var authUrl = '${authUrl}';
var consoleBaseUrl = '${consoleBaseUrl}';
var resourceUrl = '${resourceUrl}';
var masterRealm = '${masterRealm}';
</script>

View file

@ -1,10 +1,5 @@
'use strict';
var consoleBaseUrl = window.location.href;
consoleBaseUrl = consoleBaseUrl.substring(0, consoleBaseUrl.indexOf("/console"));
consoleBaseUrl = consoleBaseUrl + "/console";
var configUrl = consoleBaseUrl + "/config";
var auth = {};
var resourceBundle;
var locale = 'en';
@ -14,11 +9,11 @@ var resourceRequests = 0;
var loadingTimer = -1;
angular.element(document).ready(function () {
var keycloakAuth = new Keycloak(configUrl);
var keycloakAuth = new Keycloak(consoleBaseUrl + 'config');
function whoAmI(success, error) {
var req = new XMLHttpRequest();
req.open('GET', consoleBaseUrl + "/whoami", true);
req.open('GET', consoleBaseUrl + 'whoami', true);
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader('Authorization', 'bearer ' + keycloakAuth.token);
@ -38,7 +33,7 @@ angular.element(document).ready(function () {
function loadResourceBundle(success, error) {
var req = new XMLHttpRequest();
req.open('GET', consoleBaseUrl + '/messages.json?lang=' + locale, true);
req.open('GET', consoleBaseUrl + 'messages.json?lang=' + locale, true);
req.setRequestHeader('Accept', 'application/json');
req.onreadystatechange = function () {