KEYCLOAK-1025 Skip automatic logout from KC admin console for non-authorized users
This commit is contained in:
parent
9a9f2a17a5
commit
8b4e724aeb
4 changed files with 15 additions and 6 deletions
|
@ -64,7 +64,7 @@
|
||||||
<div data-ng-include data-src="'partials/menu.html'"></div>
|
<div data-ng-include data-src="'partials/menu.html'"></div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container" data-ng-show="auth.hasAnyAccess">
|
||||||
<div data-ng-view id="view"></div>
|
<div data-ng-view id="view"></div>
|
||||||
<div id="loading" class="loading-backdrop">
|
<div id="loading" class="loading-backdrop">
|
||||||
<div class="loading">
|
<div class="loading">
|
||||||
|
|
|
@ -10,9 +10,22 @@ module.controller('GlobalCtrl', function($scope, $http, Auth, WhoAmI, Current, $
|
||||||
$scope.serverInfo = ServerInfo.get();
|
$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) {
|
WhoAmI.get(function (data) {
|
||||||
Auth.user = data;
|
Auth.user = data;
|
||||||
Auth.loggedIn = true;
|
Auth.loggedIn = true;
|
||||||
|
Auth.hasAnyAccess = hasAnyAccess();
|
||||||
});
|
});
|
||||||
|
|
||||||
function getAccess(role) {
|
function getAccess(role) {
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="{{authUrl}}/realms/{{auth.user.realm}}/account?referrer=security-admin-console">Manage Account</a></li>
|
<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>
|
<li class="separator"><a href="" ng-click="auth.authz.logout()">Sign Out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -207,10 +207,6 @@ public class AdminConsole {
|
||||||
logger.debug("setting up realm access for a realm user");
|
logger.debug("setting up realm access for a realm user");
|
||||||
addRealmAccess(realm, user, realmAccess);
|
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();
|
return Response.ok(new WhoAmI(user.getId(), realm.getName(), displayName, createRealm, realmAccess)).build();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue