DEV Community

Cover image for Keycloak: The Open-Source Hero Behind Secure Logins
Threshika Vijayakumar
Threshika Vijayakumar

Posted on

Keycloak: The Open-Source Hero Behind Secure Logins

Every time you click “Login with Google” or “Sign in with GitHub,” a complex dance happens in the background: tokens are exchanged, your identity is verified, and permissions are granted, all in a matter of seconds.

While many developers rely on cloud services like AWS Cognito or Firebase Authentication, there’s a powerful open-source alternative that gives you full control over authentication and user management: Keycloak.

What is Keycloak?

Keycloak is an open-source Identity and Access Management (IAM) solution developed by Red Hat.
It helps developers add authentication, authorization, and single sign-on (SSO) to their applications without writing security code from scratch.

In simple terms:

Keycloak helps you manage who can access your application, how they log in, and what permissions they have.

Why Keycloak When There Are So Many Cloud Options?

You might wonder why not use AWS Cognito, Firebase Auth, or Azure AD instead?

Here’s what makes Keycloak special:

  • Open Source
  • Self-hosted
  • Easy Integration

Keycloak in a Nutshell

Realm – Your own isolated space managing users, roles, and clients. (You can have multiple realms like dev, test, prod.)

User – Represents a person or service that can log in. Can be created manually, registered, or linked via external IdPs.

Client – Any app using Keycloak for login (e.g., frontend, backend). Defines redirect URIs, access type, and permissions.

Identity Provider (IdP) – External service verifying user identity (e.g., Google, GitHub, Azure AD, AWS Cognito, GCP). Keycloak connects them all in one place.

Hands-On: Run Keycloak Using Docker

Step 1: Pull the Keycloak Image

docker pull quay.io/keycloak/keycloak:latest
Enter fullscreen mode Exit fullscreen mode

Step 2: Run Keycloak in Development Mode

docker run -d \
  --name keycloak \
  -p 8080:8080 \
  -e KEYCLOAK_ADMIN=admin \
  -e KEYCLOAK_ADMIN_PASSWORD=admin \
  quay.io/keycloak/keycloak:latest start-dev

Enter fullscreen mode Exit fullscreen mode

Step 3: Log in to the Admin Console

Go to:
http://localhost:8080
Login using:
Username: admin
Password: admin

You’ll see the Keycloak dashboard with options to manage realms, users, and clients.

Step 4: Create a Realm

Click on the top-left dropdown → Create Realm
Name it (e.g., myapp-realm)
Save

Step 5: Add a Client

Go to Clients → Create Client
Name: react-app
Root URL: http://localhost:3000 (your app’s URL)
Save and configure redirect URIs

Step 6: Add a User

Go to Users → Add User
Set username (e.g., john)
Go to Credentials tab → Set password
Enable Temporary Password = OFF

My Experience Working with Keycloak

Recently, I came across Keycloak while exploring secure authentication. I started experimenting with it, and soon I was able to integrate the latest Keycloak Quarkus version (previously, it was based on WildFly). The new Quarkus-based version felt significantly lighter, started faster, and was easier to configure, which made the entire setup experience smoother.

However, it wasn’t without challenges. One of the main issues I faced was with webhook-like event integrations, which weren’t available directly through the UI. I had to configure them manually using Keycloak’s event listener mechanism. Since Keycloak is open-source and fully extensible, I could add custom logic and workarounds, but it took some digging through the documentation to get it right.

Another challenge was handling redirect URIs and token configurations for clients. A small mismatch in redirect URLs or access type (public vs. confidential) can cause authentication loops or token errors. Understanding how Keycloak issues tokens and how the client consumes them took some trial and error, but once it clicked, the flow made perfect sense.

Despite these hurdles, the experience was amazing. Once the integration was complete, authentication and user management became seamless. It felt rewarding to see how flexible and powerful Keycloak can be when you really understand its structure and flow.

When you finally get Keycloak working after the setup struggle 😎

Final Thoughts

Authentication is a complex but critical part of every application.
Instead of building your own login system and handling tokens manually, Keycloak provides a ready-to-use, secure, and flexible identity management solution.

Whether you’re securing a single web app or managing microservices in the cloud, Keycloak simplifies identity so you can focus on building your core product.

Start your Keycloak journey today because secure login doesn’t have to be hard.

Top comments (0)