[keycloak-user] How to get online users

Stian Thorgersen stian at redhat.com
Mon Oct 6 06:44:38 EDT 2014


Hi,

Active user sessions can be retrieved through the admin rest endpoints, as well as through the Keycloak admin console.

You can retrieve all applications with active sessions and number of active users with:

  http://docs.jboss.org/keycloak/docs/1.0.1.Final/rest-api/admin/realms/%7Brealm%7D/application-session-stats/index.html

You can retrieve a list of active users per-application with:

  http://docs.jboss.org/keycloak/docs/1.0.1.Final/rest-api/admin/realms/%7Brealm%7D/applications/%7Bapp-name%7D/user-sessions/index.html

For details on how to use the admin endpoints look at "examples/preconfigured-demo/admin-access-app" in the downloads. There's also a Java admin client lib, which makes it easier to call the admin endpoints, but these methods have not been added yet.



----- Original Message -----
> From: "Jason Rodis" <jasrodis at gmail.com>
> To: keycloak-user at lists.jboss.org
> Sent: Monday, 6 October, 2014 11:40:57 AM
> Subject: [keycloak-user] How to get online users
> 
> Good morning,
> 
> I am trying to set up an application that uses:
> 
> 1. Spring 3.2.x
> 
> I used to have spring security for the authentication of the users, and I
> could get all the online users by a bean called SpringRegistryImpl. Here is
> an example how I could get all the logged in users:
> 
> In the controller class I had:
> 
> @Autowired
> private SessionRegistryImpl sessionRegistry;
> 
> and then:
> 
>             List<Object> principals = sessionRegistry.getAllPrincipals();
> 
>             for (Object principal : principals) {
>                 if (principal instanceof UserDetails) {
>            		//Add user to the list with the logged in users (in session).
>                 }
>             }
> 
> 
> Now, I have configured my application’s authentication with keycloak and
> removed spring-security.
> 
> How can I retrieve all the users in session with keycloak?
> 
> Thanks in advance,
> Jason
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
> 



More information about the keycloak-user mailing list