You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When starting the server, https transport can be set up by setting keystore containing the server certificate
and https port, optionally setting the truststore.
KeycloakServer can be configured with system properties, or through the file ~/.keycloak-server.properties. Using the
file allows persisting the settings and can also be more convenient when running from an IDE.
Available options include:
Key
Description
keycloak.port
Set the HTTP port for the server
keycloak.port.https
Set the HTTPS port for the server
keycloak.bind.address
Set the bind address for the server
resources
Loads theme resources directly from the workspace and disables caching
keycloak.theme.dir
Specifies an alternative location to load custom themes from
keycloak.theme.cacheTemplates
Disables theme template caching
keycloak.theme.cacheThemes
Disables theme caching
keycloak.theme.staticMaxAge
Sets the client-side caching max-age for theme resources
import
Imports a realm from json at startup
Default admin account
The default admin within the master realm are created with credentials:
Username: admin
Password: admin
The Keycloak test suite server will automatically create the new master realm user when the following conditions are met
Property keycloak.createAdminUser is set to true (defaults to true if not present)
There is no existing user within the master realm
Live edit of html and styles
The Keycloak test server can load resources directly from the filesystem instead of the classpath. This allows editing html, styles and updating images without restarting the server. To make the server use resources from the filesystem start with:
mvn exec:java -Pkeycloak-server -Dresources
You can also specify the theme directory used by the server with:
mvn exec:java -Pkeycloak-server -Dkeycloak.theme.dir=<PATH TO THEMES DIR>
For example to use the example themes run the server with:
NOTE: If keycloak.theme.dir is specified the default themes (base, rcue and keycloak) are loaded from the classpath
TOTP codes
To generate totp codes without Google authenticator run:
mvn exec:java -Ptotp
or run org.keycloak.testsuite.TotpGenerator from your favourite IDE!
Once started copy/paste the totp secret and press enter. To use a new secret just copy/paste and press enter again.
Mail server
The Keycloak testsuite includes a standalone mock mail server for testing email-related features such as email verification,
password reset, and other email notifications.
or run org.keycloak.testsuite.MailServer from your favourite IDE!
The mail server will start on localhost:3025 and display all received emails in the console.
Configuring Keycloak
To configure Keycloak to use the test mail server:
Open your browser and login to the Keycloak Admin Console with admin credentials.
Select the realm you want to configure from the realm dropdown in the top-left corner (e.g., master or your test
realm).
In the left sidebar, navigate to Realm settings.
Click on the Email tab.
Enter the following SMTP configuration values:
Field
Value
Description
From
auto@keycloak.org
Email address used as sender
Host
localhost
Mail server hostname
Port
3025
Mail server port
Configure optional settings:
Enable StartTLS: Check this box (Yes), or leave it unchecked (No)
Enable Authentication: Leave unchecked (No)
Enable SSL: Leave unchecked (No)
Click Save to apply the configuration.
Optional Test: Configure an email address for the admin user if not configured already. Then return to the Email tab and click Test connection to verify the mail server is reachable. You should see a success message and the test email
will appear in the mail server console output.
Testing Email Features
Once configured, you can test various email-related features:
Email Verification:
In Realm settings → Login tab, enable "Verify email".
Register a new user or update an existing user's email.
Check the mail server console for the verification email.
Password Reset:
In Realm settings → Login tab, enable "Forgot password".
Go to the login page and click "Forgot Password?".
Enter a user's email and check the mail server console.
Update Email:
Change a user's email address in the Account Console.
If email verification is enabled, check the mail server console for the confirmation email.
Event Notifications:
Configure email event listeners in Realm settings → Events
Trigger events and check the mail server console for notifications.
All emails sent by Keycloak will be captured by the test mail server and displayed in the console output with full
content including subject, recipient, and message body.
LDAP server
The Keycloak testsuite includes a standalone embedded ApacheDS-based LDAP server
for testing LDAP Federation provider and authentication features.
This allows local development and testing without requiring an external LDAP server.
or run org.keycloak.testsuite.ldap.LDAPEmbeddedServer from your favourite IDE!
Configuring LDAP in Keycloak Admin Console
Once the LDAP server is running, navigate to the Keycloak Admin Console.
Select your realm (e.g., master or your realm) from the realm dropdown in the top-left corner.
In the left navigation menu, click on User Federation.
Click on the Add LDAP provider.
LDAP Server Settings
There are additional system properties you can use to configure (See LDAPEmbeddedServer class for details). Once done, you can create LDAP Federation provider
in Keycloak admin console with the settings like:
The following users are available currently for testing:
Username
Password
Full Name
Email
jbrown
password
James Brown
jbrown@keycloak.org
bwilson
password
Bruce Wilson
bwilson@keycloak.org
To log in as one of these users:
Navigate to your realm's login page, e.g., http://localhost:8080/realms/master/account
Enter the username (e.g., jbrown) and password (password).
Click Sign In.
The user will be federated from LDAP on first login.
To verify the user was synced, go to the Keycloak Admin Console → Users and confirm
the LDAP user appears with the attribute LDAP_ID populated.
Browsing the LDAP Directory with Apache Directory Studio
Apache Directory Studio is a free GUI tool for
browsing and managing LDAP directories. It is useful for inspecting the embedded server's
directory tree during development.
Open Apache Directory Studio and go to File → New → LDAP Browser → LDAP Connection.
Enter the following connection details:
Field
Value
Connection name
Keycloak Local LDAP
Hostname
localhost
Port
10389
Encryption method
No encryption
Click Next, then enter the authentication details:
Field
Value
Authentication method
Simple Authentication
Bind DN
uid=admin,ou=system
Bind password
secret
Click Finish to save the connection, then double-click it to connect.
In the LDAP Browser panel, expand dc=keycloak,dc=org → ou=People to browse the
default users (e.g., uid=jbrown, uid=bwilson).
In your testing, you can use Apache Directory Studio to inspect the LDAP directory structure, verify user entries, and
monitor changes as you interact with Keycloak's LDAP Federation provider.
Kerberos server
To start a ApacheDS based Kerberos server for testing Kerberos + LDAP sending run:
mvn exec:java -Pkerberos
There are additional system properties you can use to configure (See LDAPEmbeddedServer and KerberosEmbeddedServer class for details) but for testing purposes default values should be good.
By default ApacheDS LDAP server will be running on localhost:10389 and Kerberos KDC on localhost:6088 .
The alternative is to start Kerberos with the alternative realm KC2.COM instead of default KEYCLOAK.ORG.
The ApacheDS server will be then started with all ports shifted by 1000 (EG. LDAP on 11389, Kerberos KDC on 7088).
This allows to start 2 kerberos servers in parallel to test things like Kerberos cross-realm trust:
Once kerberos is running, you can create LDAP Federation provider in Keycloak admin console with same settings like mentioned in previous LDAP section.
But additionally you can enable Kerberos authentication in LDAP provider with the settings like:
KeyTab: $KEYCLOAK_SOURCES/testsuite/integration-arquillian/tests/base/src/test/resources/kerberos/http.keytab (Replace $KEYCLOAK_SOURCES with correct absolute path of your sources)
Finally test the integration by retrieve kerberos ticket. In many OS you can achieve this by running command from CMD like:
kinit hnelson@KEYCLOAK.ORG
and provide password secret
Now when you access http://localhost:8081/auth/realms/master/account you should be logged in automatically as user hnelson .
Simple loadbalancer
You can run class SimpleUndertowLoadBalancer from IDE. By default, it executes the embedded undertow loadbalancer running on http://localhost:8180, which communicates with 2 backend Keycloak nodes
running on http://localhost:8181 and http://localhost:8182 . See javadoc for more details.
Then once CLI is started, you can use command help to see all the available commands.
Creating many users
For create many users you can use command createUsers
For example this will create 500 users test0, test1, test2, ... , test499 in realm demo and each 100 users in separate transaction. All users will be granted realm roles user and admin :
createUsers test test demo 0 500 100 user,admin
Check count of users:
getUsersCount demo
Check if concrete user was really created:
getUser demo test499
Creating many offline sessions
For create many offline sessions you can use command persistSessions . For example create 50000 sessions (each 500 in separate transaction) with command:
persistSessions 50000 500
Once users or sessions are created, you can restart to ensure the startup import of offline sessions will be triggered and you can see impact on startup time. After restart you can use command:
size
to doublecheck total count of sessions in infinispan (it will be 2 times as there is also 1 client session per each user session created)