Creating Users
In this lesson, we'll set up our first user in Keycloak, which we'll use later to test our authentication system for the restaurant review platform.
Setting Up Keycloak Realm
Before we can create users, we need to set up a dedicated realm in Keycloak for our application.
A realm in Keycloak is like a separate universe for your application's users and security settings.
If you haven't already, here's how to create a new realm:
-
Log into the Keycloak Admin Console using your administrator credentials.
-
Click on the dropdown in the top-left corner that says "master".
-
Click "Create Realm".
-
Enter "restaurant-review" as the realm name.
-
Click "Create".
Creating Your First User
Now that we have our realm set up, let's create a test user.
Follow these steps to create a user:
-
In the left sidebar, click on "Users".
-
Click the "Add user" button.
-
Fill in the following details:
Username: testuser
Email: testuser@example.com
First Name: Test
Last Name: User-
Make sure "Email Verified" is switched ON.
-
Click "Create".
Setting User Credentials
For development purposes, we'll set a simple password for our test user.
Here's how to set the password:
-
After creating the user, go to the "Credentials" tab.
-
Click "Set password".
-
Enter these details:
Password: password
Password Confirmation: password-
Switch "Temporary" to OFF so the user won't need to change their password on first login.
-
Click "Save".
Development Considerations
Setting passwords manually like this is convenient during development, but it's not recommended for production environments.
In production, you should:
- Use strong password policies
- Enable email verification
- Implement password reset flows
- Consider enabling two-factor authentication
These security measures help protect your users and their data.
Summary
- Added a new user
testuserwith basic profile information - Set up user credentials with password
password