KEYCLOAK-1025 Skip automatic logout from KC admin console for non-authorized users

This commit is contained in:
mposolda 2015-02-06 18:13:17 +01:00
parent 9a9f2a17a5
commit 8b4e724aeb
4 changed files with 15 additions and 6 deletions

View file

@ -64,7 +64,7 @@
<div data-ng-include data-src="'partials/menu.html'"></div>
</header>
<div class="container">
<div class="container" data-ng-show="auth.hasAnyAccess">
<div data-ng-view id="view"></div>
<div id="loading" class="loading-backdrop">
<div class="loading">

View file

@ -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) {

View file

@ -20,7 +20,7 @@
</a>
<ul class="dropdown-menu">
<li><a href="{{authUrl}}/realms/{{auth.user.realm}}/account?referrer=security-admin-console">Manage Account</a></li>
<li><a href="#/server-info">Server Info</a></li>
<li data-ng-show="auth.hasAnyAccess"><a href="#/server-info">Server Info</a></li>
<li class="separator"><a href="" ng-click="auth.authz.logout()">Sign Out</a></li>
</ul>
</li>

View file

@ -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();
}