Keycloak on Docker & First Setup

Erhan Yıldırım
3 min readFeb 18, 2021

In this post, I would like to show you how to setup Keycloak on Docker.

First, What is Keycloak ?

Keycloak is an open source Identity and Access Management solution targeted towards modern applications and services.

Keycloak offers features such as Single-Sign-On (SSO), Identity Brokering and Social Login, User Federation, Client Adapters, an Admin Console, and an Account Management Console.

Start Keycloak

docker run -p 8080:8080 -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin quay.io/keycloak/keycloak:12.0.3 

This will start Keycloak exposed on the local port 8080. It will also create an initial admin user with username admin and password admin.

Wooalaa !!

First we’ll enter the initial admin user credentials. (user: admin, pass: admin)

A successful login will take us to the console and open up the default Master realm for us.

Realm

We need to create our custom Realm.

On the upper left upper corner, click the Add realm button.

You can give any name.

Role

After created realm, we have to need roles for incoming users.

Created ‘Admin’ role details be like;

Also i created role as ‘User’ too.

Client

Now we’ll navigate to the Clients page. And click the ‘Create’ button.

Our created ‘web-client’ client details;

After created client, we have to specify at least one ‘Valid Redirect URL’ that will use this client for authentication.

Example: http://localhost:8081/*

User

User — Credentials

After created user, in ‘Credential’ tab, we have to set password.

Notice that ‘Temporary’ field must be set OFF.

User — Role Mapping

After all these configurations, let’s check it is working properly;

First we need go back to client detail page, change the Access Type as ‘confidential’.

After save, ‘Credential’ tab will be appear. You can copy your secret for sending request.

Test

Request must be like;

And response:

References

https://www.keycloak.org/getting-started/getting-started-docker

--

--