Keycloak Logs - Device Information

Hi,

We’re currently deploying keycloak in a docker container and I’m trying to establish if it’s possible to identify the source of a authentication request. Any information really that can provide guidance on what type of device requested the authentication (mobile, tablet, computer etc).

I have established that I can get the source IP in the logs which is a great start, however in the Keycloak manual Personal data collected by Keycloak

By default, Keycloak collects the following:

** Basic user profile, such as email, firstname, and lastname*
** Basic user profile used for social accounts and references to the social account when using a social login*
** Device information collected for audit and security purposes, such as the IP address, operating system name, and browser name it says the following… .*

The part that has my attention is the reference to operating system name and browser name. Can anyone provide further details on this? I’d really like to see these in the logs.

How can I log the OS name and Browser name?
How can I view the logs which show the OS name and Browser name?
Where are the logs stored for this information?

Kind Regards,

1 Like

I am also interested in capturing/viewing OS & Browser as well. Did you figure this out yet? I searched thru all the DB tables but don’t see anything obvious. Ideally, I would like to capture the user-agent with all the user login events. Is this possible out-of-the-box or would I need to implement my own event listener and log it to ELK or something like that? Thanks.

Just thought I’d reply to be kind. I stopped pursuing this, there is some basic information such as source IP that gets logged in the gui if enabled, but thats about all I could find.

good luck

I am aware this question is more than three years old, but In case someone is looking, here is what I found. The device, browser, OS information are provided by the class DeviceRepresentation. The class DeviceActivityManager provide an instance of DeviceRepresentation, via a static method:
DeviceRepresentation deviceRepresentation = DeviceActivityManager.getCurrentDevice(userSession);
String browser =deviceRepresentation.getBrowser();
String device = deviceRepresentation.getDevice();
String os =deviceRepresentation.getOs();
Boolean isMobile =deviceRepresentation.isMobile();
See the javadocs links below for more information.

https://www.keycloak.org/docs-api/21.1.0/javadocs/org/keycloak/device/DeviceActivityManager.html
https://www.keycloak.org/docs-api/21.1.0/javadocs/org/keycloak/representations/account/DeviceRepresentation.html

1 Like