Skip to content
Authentication Flows

Authentication Flows

Use authentication flow resources when the default Keycloak login process is not enough. They let you define custom browser, registration, direct-grant, or client-authentication flows; nest subflows; add execution steps such as MFA, OTP, WebAuthn, or identity-provider redirects; and bind the finished flow to the realm behavior that should use it.

API Reference

KindAPI GroupTerraformCRD Explorer
Flowauthenticationflow.keycloak.crossplane.io/v1alpha1keycloak_authentication_flowView CRD Schema
Subflowauthenticationflow.keycloak.crossplane.io/v1alpha1keycloak_authentication_subflowView CRD Schema
Executionauthenticationflow.keycloak.crossplane.io/v1alpha1keycloak_authentication_executionView CRD Schema
ExecutionConfigauthenticationflow.keycloak.crossplane.io/v1alpha1keycloak_authentication_execution_configView CRD Schema
Bindingsauthenticationflow.keycloak.crossplane.io/v1alpha1keycloak_authentication_bindingsView CRD Schema

Working YAML examples

Flow

Use a Flow to create the top-level container for a custom authentication sequence.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: Flow
metadata:
  name: flow
spec:
  deletionPolicy: Delete
  forProvider:
    alias: my-flow-alias
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
  providerConfigRef:
    name: "keycloak-provider-config"

Subflow

Use a Subflow to group steps inside a parent flow and apply its own requirement.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: Subflow
metadata:
  name: subflow
  labels:
    subflow-type: test-subflow
spec:
  deletionPolicy: Delete
  forProvider:
    alias: my-subflow-alias-1
    parentFlowAliasRef:
      name: flow
      policy:
        resolve: Always
    providerId: basic-flow
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
    requirement: ALTERNATIVE
  providerConfigRef:
    name: "keycloak-provider-config"

Execution using parentFlowAliasRef

Use an Execution directly under a top-level flow when the step should run without an intermediate subflow.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: Execution
metadata:
  name: execution-one
spec:
  deletionPolicy: Delete
  forProvider:
    authenticator: auth-cookie
    parentFlowAliasRef:
      name: flow
      policy:
        resolve: Always
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
    requirement: ALTERNATIVE
  providerConfigRef:
    name: "keycloak-provider-config"

Execution using parentSubflowAliasRef

Use parentSubflowAliasRef when the execution should be nested inside a specific subflow object.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: Execution
metadata:
  name: execution-in-subflow-ref
spec:
  deletionPolicy: Delete
  forProvider:
    authenticator: auth-username-password-form
    parentSubflowAliasRef:
      name: subflow
      policy:
        resolve: Always
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
    requirement: REQUIRED
  providerConfigRef:
    name: "keycloak-provider-config"

Execution using parentSubflowAliasSelector

Use the selector form when you want to target a subflow by labels instead of by a fixed name.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: Execution
metadata:
  name: execution-in-subflow-selector
spec:
  deletionPolicy: Delete
  forProvider:
    authenticator: auth-otp-form
    parentSubflowAliasSelector:
      matchLabels:
        subflow-type: test-subflow
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
    requirement: REQUIRED
  providerConfigRef:
    name: "keycloak-provider-config"

ExecutionConfig

Use ExecutionConfig when an execution needs extra configuration, such as the default identity provider for an IdP redirector.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: ExecutionConfig
metadata:
  name: execution-identity-redirect-config
spec:
  deletionPolicy: Delete
  forProvider:
    alias: my-config-alias
    config:
      defaultProvider: my-config-default-idp
    executionIdRef:
      name: execution-identity-redirect
      policy:
        resolve: Always
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
  providerConfigRef:
    name: "keycloak-provider-config"

Bindings

Use Bindings to assign your custom flow to browser, registration, direct grant, or other realm authentication entry points.

apiVersion: authenticationflow.keycloak.crossplane.io/v1alpha1
kind: Bindings
metadata:
  name: browser-authentication-binding
spec:
  deletionPolicy: Delete
  forProvider:
    dockerAuthenticationFlowRef:
      name: "flow"
      policy:
        resolve: Always
    realmIdRef:
      name: "dev"
      policy:
        resolve: Always
  providerConfigRef:
    name: "keycloak-provider-config"

Key fields

Flow and Subflow

FieldApplies toWhy it matters
aliasFlow, SubflowStable name used by executions and bindings.
realmIdRefFlow, SubflowSelects the realm that owns the flow.
providerIdSubflowChooses the Keycloak flow type, typically basic-flow.
parentFlowAliasRefSubflowAttaches the subflow to its parent flow.
requirementSubflowControls whether the subflow is REQUIRED, ALTERNATIVE, and so on.

Execution and ExecutionConfig

FieldApplies toWhy it matters
authenticatorExecutionSelects the actual Keycloak authenticator, such as auth-cookie or auth-otp-form.
parentFlowAliasRefExecutionPlaces the execution directly under a top-level flow.
parentSubflowAliasRef / parentSubflowAliasSelectorExecutionPlaces the execution inside a specific subflow.
requirementExecutionDetermines whether the authenticator is required, optional, or alternative.
executionIdRefExecutionConfigResolves the execution that receives the configuration block.
configExecutionConfigHolds authenticator-specific configuration such as defaultProvider.

Bindings

FieldWhy it matters
realmIdRefSelects the realm whose authentication bindings are being changed.
browserAuthenticationFlowRefBinds a custom flow to browser logins.
registrationFlowRefBinds a custom flow to self-registration.
directGrantFlowRefBinds a flow to direct access grant authentication.
resetCredentialsFlowRefBinds a flow to reset-credentials behavior.
clientAuthenticationFlowRefBinds a flow to client authentication.
dockerAuthenticationFlowRefBinds a flow to Docker authentication.

Related Resources

  • Identity Providers — Combine IdP redirectors and external authentication with custom flows.
  • Clients — Understand which applications consume the flows you bind.
  • Realms — Manage the realm that owns the flows and bindings.