docker run -p 8081:8080 -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin quay.io/keycloak/keycloak:25.0.5 start-dev
- Go to the Keycloak Admin Console (http://localhost:8081/admin).
- Log in with the username and password you created earlier. (admin admin)
A realm in Keycloak is equivalent to a tenant. Each realm allows an administrator to create isolated groups of applications and users. Initially, Keycloak includes a single realm, called master. Use this realm only for managing Keycloak and not for managing any applications.
Use these steps to create the first realm.
- Open the Keycloak Admin Console.
- Click Keycloak next to master realm, then click Create Realm.
- Enter
myrealm
in the Realm name field.
Click Create.
Initially, the realm has no users. Use these steps to create a user.
- Verify that you are still in the
myrealm
realm, which is shown above the word Manage. - Click Users in the left-hand menu.
- Click Add user.
- Fill in the form with the following values:
- Username:
myuser
- First name: any first name
- Last name: any last name
- Username:
- Click Create.
This user needs a password to log in. To set the initial password:
- Click Credentials at the top of the page.
- Fill in the Set password form with a password.
- Toggle Temporary to Off so that the user does not need to update this password at the first login.
- Open the Keycloak Account Console (http://localhost:8081/realms/myrealm/account).
- Log in with
myuser
and the password you created earlier.
As a user in the Account Console, you can manage your account including modifying your profile, adding two-factor authentication, and including identity provider accounts.
- Open the Keycloak Admin Console.
- Click the word master in the top-left corner, then click
myrealm
. - Click Clients.
- Click Create client
- Fill in the form with the following values:
- Client type: OpenID Connect
- Client ID:
myrealmclient
- Click Next
- Confirm that Standard flow is enabled.
- Click Next.
- Make these changes under Login settings.
- Set Valid redirect URIs to
*
- Set Web origins to
*
- Under Capability config, turn on the following things:
- Client authentication
- Authorization
- OAuth 2.0 Device Authorization Grant
- Direct access grants
- Click Save.
To confirm the client was created successfully, you can use the SPA testing application on the Keycloak website (https://www.keycloak.org/app/).
- Open (https://www.keycloak.org/app/) .
- Click Save to use the default configuration.
- Click Sign in to authenticate to this application using the Keycloak server you started earlier
- Open
appsettings.Development.json
and paste your client secret into the corresponding field. (myrealm -> Clients -> myrealmclient -> Credentials)