Auth

Keycloak

An open source identity and access management solution with SSO, OIDC, SAML and roles.

What it is

Keycloak is an identity server you host yourself. It manages users, roles, groups and sessions, and apps delegate sign-in to it through OIDC, OAuth 2.0 or SAML.

It supports social login, federation with LDAP and Active Directory, multi-factor auth, passkeys and custom themes. The structure: realms (isolated spaces), clients (apps), users, roles.

Red Hat started the project, and in 2023 it was accepted into CNCF as incubating. It gives full control over data but needs administration, upgrades and your own infrastructure.

Use it when

  • You need SSO for many internal apps without per-user fees.
  • Data must stay on your own infrastructure.
  • Integration with corporate LDAP or Active Directory.

Avoid it when

  • A small team with no time to operate a service: a managed Auth0 or Clerk fits better.
  • A simple app with one sign-in method.

Key concepts

Realm
An isolated space of users, clients and settings.
Client
An app or API that trusts Keycloak.
Roles / Groups
Access rights at realm or client level and user grouping.
Identity brokering
Sign-in through external providers (Google, GitHub, another IdP).

Example

Running Keycloak locally in dev mode.

Interview questions

  1. 1. What is a realm in Keycloak?

    An isolated container for users, roles, clients and settings. Realms cannot see each other's data, so it is handy for separating environments or customers.

  2. 2. How does an app integrate with Keycloak?

    It registers as a client and uses OIDC Authorization Code with PKCE, then verifies signed tokens with keys from the JWKS.

  3. 3. How does Keycloak differ from Auth0?

    Keycloak is open source and self-hosted, Auth0 is a managed paid service. The first gives control and a low per-user cost, the second saves operations time.

Interview questions from the bank

Logos belong to their owners and are used for identification only. Icons: Simple Icons (CC0), Devicon (MIT).