From 8b4e724aeb8bddb475d3643549ac349c602b735e Mon Sep 17 00:00:00 2001 From: mposolda Date: Fri, 6 Feb 2015 18:13:17 +0100 Subject: [PATCH] KEYCLOAK-1025 Skip automatic logout from KC admin console for non-authorized users --- .../resources/theme/admin/base/resources/index.html | 2 +- .../admin/base/resources/js/controllers/realm.js | 13 +++++++++++++ .../theme/admin/base/resources/partials/menu.html | 2 +- .../services/resources/admin/AdminConsole.java | 4 ---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html index 3e502950b6..6f56ee6f04 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/index.html @@ -64,7 +64,7 @@
-
+
diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js index c9dfd55200..ec05bb05e5 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/js/controllers/realm.js @@ -10,9 +10,22 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, WhoAmI, Current, $ $scope.serverInfo = ServerInfo.get(); }; + function hasAnyAccess() { + var realmAccess = Auth.user && Auth.user['realm_access']; + if (realmAccess) { + for (var p in realmAccess){ + return true; + } + return false; + } else { + return false; + } + } + WhoAmI.get(function (data) { Auth.user = data; Auth.loggedIn = true; + Auth.hasAnyAccess = hasAnyAccess(); }); function getAccess(role) { diff --git a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html index d7b6d7a4dd..4c206fb5fe 100755 --- a/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html +++ b/forms/common-themes/src/main/resources/theme/admin/base/resources/partials/menu.html @@ -20,7 +20,7 @@ diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java index 1e408651cc..0f8df52737 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AdminConsole.java @@ -207,10 +207,6 @@ public class AdminConsole { logger.debug("setting up realm access for a realm user"); addRealmAccess(realm, user, realmAccess); } - if (realmAccess.size() == 0) { - return Response.status(401).build(); - } - return Response.ok(new WhoAmI(user.getId(), realm.getName(), displayName, createRealm, realmAccess)).build(); }