2014-08-27 10:41:40 +00:00
|
|
|
<chapter id="events">
|
|
|
|
<title>Events</title>
|
2014-05-27 12:40:23 +00:00
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
Keycloak provides an Events SPI that makes it possible to register listeners for user related events, for example
|
|
|
|
user logins. There are two interfaces that can be implemented, the first is a pure listener, the second is a events
|
|
|
|
store which listens for events, but is also required to store events. An events store provides a way for the admin
|
|
|
|
and account management consoles to view events.
|
2014-05-27 12:40:23 +00:00
|
|
|
</para>
|
|
|
|
<section>
|
2014-08-27 10:41:40 +00:00
|
|
|
<title>Event types</title>
|
2014-05-27 12:40:23 +00:00
|
|
|
<para>
|
|
|
|
Login events:
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>Login - A user has logged in</listitem>
|
|
|
|
<listitem>Register - A user has registered</listitem>
|
|
|
|
<listitem>Logout - A user has logged out</listitem>
|
|
|
|
<listitem>Code to Token - An application/client has exchanged a code for a token</listitem>
|
|
|
|
<listitem>Refresh Token - An application/client has refreshed a token</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
Account events:
|
2014-05-27 12:40:23 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>Social Link - An account has been linked to a social provider</listitem>
|
|
|
|
<listitem>Remove Social Link - A social provider has been removed from an account</listitem>
|
|
|
|
<listitem>Update Email - The email address for an account has changed</listitem>
|
|
|
|
<listitem>Update Profile - The profile for an account has changed</listitem>
|
|
|
|
<listitem>Send Password Reset - A password reset email has been sent</listitem>
|
|
|
|
<listitem>Update Password - The password for an account has changed</listitem>
|
|
|
|
<listitem>Update TOTP - The TOTP settings for an account has changed</listitem>
|
|
|
|
<listitem>Remove TOTP - TOTP has been removed from an account</listitem>
|
|
|
|
<listitem>Send Verify Email - A email verification email has been sent</listitem>
|
|
|
|
<listitem>Verify Email - The email address for an account has been verified</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
For all events there is a corresponding error event.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
<section>
|
2014-08-27 10:41:40 +00:00
|
|
|
<title>Event Listener</title>
|
2014-05-27 12:40:23 +00:00
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
Keycloak comes with an Email Event Listener and a JBogg Logging Event Listener. The Email Event Listener
|
|
|
|
sends an email to the users account when an event occurs. The JBoss Logging Event Listener writes to a log
|
2014-05-27 12:40:23 +00:00
|
|
|
file when an events occurs.
|
|
|
|
</para>
|
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
The Email Event Listener only supports the following events at the moment:
|
2014-05-27 12:40:23 +00:00
|
|
|
<itemizedlist>
|
|
|
|
<listitem>Login Error</listitem>
|
|
|
|
<listitem>Update Password</listitem>
|
|
|
|
<listitem>Update TOTP</listitem>
|
|
|
|
<listitem>Remove TOTP</listitem>
|
|
|
|
</itemizedlist>
|
|
|
|
You can exclude one or more events by editing <literal>standalone/configuration/keycloak-server.json</literal>
|
|
|
|
and adding for example:
|
|
|
|
<programlisting><![CDATA[
|
2014-08-27 10:41:40 +00:00
|
|
|
"eventListener": {
|
2014-05-27 12:40:23 +00:00
|
|
|
"email": {
|
|
|
|
"exclude-events": [ "UPDATE_TOTP", "REMOVE_TOTP" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]></programlisting>
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
2014-08-27 10:41:40 +00:00
|
|
|
<title>Event Store</title>
|
2014-05-27 12:40:23 +00:00
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
Event Store listen for events and is expected to persist the events to make it possible to query for them
|
2014-05-27 12:40:23 +00:00
|
|
|
later. This is used by the admin console and account management to view events. Keycloak includes providers
|
2014-08-27 10:41:40 +00:00
|
|
|
to persist events to JPA and Mongo.
|
2014-05-27 12:40:23 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
You can specify events to include or exclude by editing <literal>standalone/configuration/keycloak-server.json</literal>,
|
|
|
|
and adding for example:
|
|
|
|
<programlisting><![CDATA[
|
2014-08-27 10:41:40 +00:00
|
|
|
"eventsStore": {
|
2014-05-27 12:40:23 +00:00
|
|
|
"jpa": {
|
|
|
|
"exclude-events": [ "LOGIN", "REFRESH_TOKEN", "CODE_TO_TOKEN" ]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]]></programlisting>
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
2014-08-27 10:41:40 +00:00
|
|
|
<title>Configure Events Settings for Realm</title>
|
2014-05-27 12:40:23 +00:00
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
To enable persisting of events for a realm you first need to make sure you have a event store provider registered for Keycloak.
|
|
|
|
By default the JPA event store provider is registered. Once you've done that open the admin console, select the
|
|
|
|
realm you're configuring, select <literal>Events</literal>. Then click on <literal>Config</literal>.
|
|
|
|
You can enable storing events for your realm by toggling <literal>Save Events</literal> to ON. You can also set
|
|
|
|
an expiration on events. This will periodically delete events from the database that are older than the specified
|
2014-05-27 12:40:23 +00:00
|
|
|
time.
|
|
|
|
</para>
|
|
|
|
<para>
|
2014-08-27 10:41:40 +00:00
|
|
|
To configure listeners for a realm on the same page as above add one or more event listeners to the
|
|
|
|
<literal>Listeners</literal> select box. This will allow you to enable any registered event listeners with the
|
2014-05-27 12:40:23 +00:00
|
|
|
realm.
|
|
|
|
</para>
|
|
|
|
</section>
|
|
|
|
</chapter>
|