diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js index bfb76f7e70..bce292ed87 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/app.js @@ -176,6 +176,21 @@ module.config([ '$routeProvider', function($routeProvider) { }, controller : 'UserRoleMappingCtrl' }) + .when('/realms/:realm/users/:user/sessions', { + templateUrl : 'partials/user-sessions.html', + resolve : { + realm : function(RealmLoader) { + return RealmLoader(); + }, + user : function(UserLoader) { + return UserLoader(); + }, + stats : function(UserSessionStatsLoader) { + return UserSessionStatsLoader(); + } + }, + controller : 'UserSessionsCtrl' + }) .when('/realms/:realm/users', { templateUrl : 'partials/user-list.html', resolve : { @@ -292,6 +307,21 @@ module.config([ '$routeProvider', function($routeProvider) { }, controller : 'ApplicationClaimsCtrl' }) + .when('/realms/:realm/applications/:application/sessions', { + templateUrl : 'partials/application-sessions.html', + resolve : { + realm : function(RealmLoader) { + return RealmLoader(); + }, + application : function(ApplicationLoader) { + return ApplicationLoader(); + }, + stats : function(ApplicationSessionStatsLoader) { + return ApplicationSessionStatsLoader(); + } + }, + controller : 'ApplicationSessionsCtrl' + }) .when('/realms/:realm/applications/:application/credentials', { templateUrl : 'partials/application-credentials.html', resolve : { @@ -540,6 +570,18 @@ module.config([ '$routeProvider', function($routeProvider) { }, controller : 'RealmRevocationCtrl' }) + .when('/realms/:realm/sessions/realm', { + templateUrl : 'partials/session-realm.html', + resolve : { + realm : function(RealmLoader) { + return RealmLoader(); + }, + stats : function(RealmSessionStatsLoader) { + return RealmSessionStatsLoader(); + } + }, + controller : 'RealmSessionStatsCtrl' + }) .otherwise({ templateUrl : 'partials/notfound.html' diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js index 27607e960c..d7416a07e3 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/applications.js @@ -43,6 +43,45 @@ module.controller('ApplicationCredentialsCtrl', function($scope, $location, real }); }); +module.controller('ApplicationSessionsCtrl', function($scope, realm, stats, application, + ApplicationLogoutUser, + ApplicationLogoutAll, + ApplicationSessionStats, + ApplicationSessionStatsWithUsers, + $location, Dialog, Notifications) { + $scope.realm = realm; + $scope.stats = stats; + $scope.users = {}; + $scope.application = application; + + $scope.toDate = function(val) { + return new Date(val); + }; + + $scope.loadUsers = function() { + ApplicationSessionStatsWithUsers.get({ realm : realm.realm, application: $scope.application.name }, function(updated) { + $scope.stats = updated; + $scope.users = updated.users; + }) + }; + + $scope.logoutAll = function() { + ApplicationLogoutAll.save({realm : realm.realm, application: $scope.application.name}, function () { + Notifications.success('Logged out all users'); + $scope.loadUsers(); + }); + }; + + $scope.logoutUser = function(user) { + console.log('Trying to logout user: ' + user); + ApplicationLogoutUser.save({realm : realm.realm, application: $scope.application.name, user: user}, function () { + Notifications.success('Logged out user' + user); + $scope.loadUsers(); + }); + }; + +}); + module.controller('ApplicationClaimsCtrl', function($scope, realm, application, claims, ApplicationClaims, $http, $location, Dialog, Notifications) { diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js index cb0fa24800..d2e4e68553 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/realm.js @@ -690,6 +690,26 @@ module.controller('RealmKeysDetailCtrl', function($scope, Realm, realm, $http, $ }; }); +module.controller('RealmSessionStatsCtrl', function($scope, realm, stats, RealmSessionStats, RealmLogoutAll, Notifications) { + $scope.realm = realm; + $scope.stats = stats; + + console.log(stats); + + $scope.logoutAll = function() { + RealmLogoutAll.save({realm : realm.realm}, function () { + Notifications.success('Logged out all users'); + RealmSessionStats.get({realm: realm.realm}, function(updated) { + Notifications.success('Logged out all users'); + $scope.stats = updated; + }) + }); + }; + + +}); + + module.controller('RealmRevocationCtrl', function($scope, Realm, RealmPushRevocation, realm, $http, $location, Dialog, Notifications) { $scope.realm = angular.copy(realm); diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js index b0048a983b..178e26b6ab 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/controllers/users.js @@ -118,6 +118,35 @@ module.controller('UserRoleMappingCtrl', function($scope, $http, realm, user, ro }); +module.controller('UserSessionsCtrl', function($scope, realm, user, stats, UserLogout, ApplicationLogoutUser, UserSessionStats, Notifications) { + $scope.realm = realm; + $scope.user = user; + $scope.stats = stats; + + $scope.logoutAll = function() { + UserLogout.save({realm : realm.realm, user: user.username}, function () { + Notifications.success('Logged out user in all applications'); + UserSessionStats.get({realm: realm.realm, user: user.username}, function(updated) { + $scope.stats = updated; + }) + }); + }; + + $scope.logoutApplication = function(app) { + console.log('log user out of app: ' + app); + ApplicationLogoutUser.save({realm : realm.realm, application: app, user: user.username}, function () { + Notifications.success('Logged out user from application'); + UserSessionStats.get({realm: realm.realm, user: user.username}, function(updated) { + $scope.stats = updated; + }) + }); + }; + + + +}); + + module.controller('UserListCtrl', function($scope, realm, User) { $scope.realm = realm; $scope.searchQuery = function() { diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js index d5b391772d..84f8dbce8d 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/loaders.js @@ -48,20 +48,37 @@ module.factory('RealmLoader', function(Loader, Realm, $route, $q) { }); module.factory('UserListLoader', function(Loader, User, $route, $q) { - return Loader.query(User, function() { - return { - realm : $route.current.params.realm - } - }); + return Loader.query(User, function() { + return { + realm : $route.current.params.realm + } + }); +}); + +module.factory('RealmSessionStatsLoader', function(Loader, RealmSessionStats, $route, $q) { + return Loader.get(RealmSessionStats, function() { + return { + realm : $route.current.params.realm + } + }); }); module.factory('UserLoader', function(Loader, User, $route, $q) { - return Loader.get(User, function() { - return { - realm : $route.current.params.realm, - userId : $route.current.params.user - } - }); + return Loader.get(User, function() { + return { + realm : $route.current.params.realm, + userId : $route.current.params.user + } + }); +}); + +module.factory('UserSessionStatsLoader', function(Loader, UserSessionStats, $route, $q) { + return Loader.get(UserSessionStats, function() { + return { + realm : $route.current.params.realm, + user : $route.current.params.user + } + }); }); module.factory('RoleLoader', function(Loader, Role, $route, $q) { @@ -91,6 +108,15 @@ module.factory('ApplicationRoleLoader', function(Loader, ApplicationRole, $route }); }); +module.factory('ApplicationSessionStatsLoader', function(Loader, ApplicationSessionStats, $route, $q) { + return Loader.get(ApplicationSessionStats, function() { + return { + realm : $route.current.params.realm, + application : $route.current.params.application + } + }); +}); + module.factory('ApplicationClaimsLoader', function(Loader, ApplicationClaims, $route, $q) { return Loader.get(ApplicationClaims, function() { return { diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js b/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js index 355091b171..cb31b5e842 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js +++ b/admin-ui/src/main/resources/META-INF/resources/admin/js/services.js @@ -147,14 +147,27 @@ module.factory('ServerInfo', function($resource) { }); module.factory('User', function($resource) { - return $resource('/auth/rest/admin/realms/:realm/users/:userId', { - realm : '@realm', - userId : '@userId' - }, { + return $resource('/auth/rest/admin/realms/:realm/users/:userId', { + realm : '@realm', + userId : '@userId' + }, { update : { method : 'PUT' } - }); + }); +}); + +module.factory('UserSessionStats', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/users/:user/session-stats', { + realm : '@realm', + user : '@user' + }); +}); +module.factory('UserLogout', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/users/:user/logout', { + realm : '@realm', + user : '@user' + }); }); module.factory('UserCredentials', function($resource) { @@ -241,6 +254,13 @@ module.factory('RealmPushRevocation', function($resource) { }); }); +module.factory('RealmSessionStats', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/session-stats', { + realm : '@realm' + }); +}); + + module.factory('RoleApplicationComposites', function($resource) { return $resource('/auth/rest/admin/realms/:realm/roles-by-id/:role/composites/applications/:application', { realm : '@realm', @@ -456,6 +476,7 @@ module.factory('ApplicationRole', function($resource) { } }); }); + module.factory('ApplicationClaims', function($resource) { return $resource('/auth/rest/admin/realms/:realm/applications/:application/claims', { realm : '@realm', @@ -467,6 +488,39 @@ module.factory('ApplicationClaims', function($resource) { }); }); +module.factory('ApplicationSessionStats', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/applications/:application/session-stats', { + realm : '@realm', + application : "@application" + }); +}); + +module.factory('ApplicationSessionStatsWithUsers', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/applications/:application/session-stats?users=true', { + realm : '@realm', + application : "@application" + }); +}); + +module.factory('ApplicationLogoutAll', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/applications/:application/logout-all', { + realm : '@realm', + application : "@application" + }); +}); +module.factory('ApplicationLogoutUser', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/applications/:application/logout-user/:user', { + realm : '@realm', + application : "@application", + user : "@user" + }); +}); +module.factory('RealmLogoutAll', function($resource) { + return $resource('/auth/rest/admin/realms/:realm/logout-all', { + realm : '@realm' + }); +}); + module.factory('ApplicationPushRevocation', function($resource) { return $resource('/auth/rest/admin/realms/:realm/applications/:application/push-revocation', { realm : '@realm', diff --git a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-claims.html b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-claims.html index 2b2e34bf61..f33e8cdbce 100755 --- a/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-claims.html +++ b/admin-ui/src/main/resources/META-INF/resources/admin/partials/application-claims.html @@ -8,6 +8,7 @@
  • Claims
  • Scope
  • Revocation
  • +
  • Sessions