Skip to main content

Integrate with Keycloak

Support level: Community

What is Keycloak

Keycloak is an open-source Identity and Access Management (IAM) platform. It can be used both as an Identity Provider and as an application.

-- https://keycloak.org

Preparation

The following placeholders are used in this guide:

  • keycloak.company is the FQDN of the Keycloak installation.
  • authentik.company is the FQDN of the authentik installation.
info

This documentation lists only the settings that you need to change from their default values. Be aware that any changes other than those explicitly mentioned in this guide could cause issues accessing your application.

Configuration methods

Keycloak can be configured to use either OIDC or SAML for federated login sources. This guide covers both methods.

authentik configuration

To support the integration of Keycloak with authentik, you need to create an application/provider pair in authentik.

Create an application and provider in authentik

  1. Log in to authentik as an administrator and open the authentik Admin interface.

  2. Navigate to Applications > Applications and click Create with Provider to create an application and provider pair. (Alternatively you can first create a provider separately, then create the application and connect it with the provider.)

    • Application: provide a descriptive name, an optional group for the type of application, the policy engine mode, and optional UI settings.
    • Choose a Provider type: select OAuth2/OpenID Connect as the provider type.
    • Configure the Provider: provide a name (or accept the auto-provided name), the authorization flow to use for this provider, and the following required configurations.
      • Note the Client ID, Client Secret, and slug values because they will be required later.
      • Set a Strict redirect URI to https://keycloak.company/access/oidc/callback.
      • Set the Logout URI to https://keycloak.company/realms/<keycloak-realm-name>/protocol/openid-connect/logout/backchannel-logout.
      • Set the Logout Method to Back-channel.
      • Select any available signing key.
    • Configure Bindings (optional): you can create a binding (policy, group, or user) to manage the listing and access to applications on a user's My applications page.
  3. Click Submit to save the new application and provider.

Keycloak configuration

  1. Log in to Keycloak as an administrator.

  2. Navigate to Configure > Identity Providers, click OpenID Connect v1.0 and set the following fields:

    • Discovery URL: https://authentik.company/application/o/<slug>/.well-known/openid-configuration
    • Client ID: enter the client ID from authentik.
    • Client secret: enter the client secret from authentik.
  3. Click Submit.

Configuration verification

To ensure that authentik is correctly integrated with Keycloak, log out and then log back in by clicking SAML or OIDC on the login screen. You should be redirected to authentik to log in, and if the process is successful, you'll be taken to the Keycloak dashboard.

Resources