Configure Keycloak authentication methods
What you’ll accomplish
Section titled “What you’ll accomplish”You’ll enable or disable the authentication methods available on the UDS Core login page (including username/password, X.509/CAC certificates, WebAuthn, OTP, and social login) using bundle overrides. No image rebuild is required.
Prerequisites
Section titled “Prerequisites”- UDS Core deployed
- UDS CLI installed
- UDS Registry account created and authenticated locally with a read token
Before you begin
Section titled “Before you begin”UDS Core ships with all major authentication flows enabled by default. Use realmAuthFlows bundle overrides to selectively enable or disable them for your environment.
| Setting | Default | Description |
|---|---|---|
USERNAME_PASSWORD_AUTH_ENABLED | true | Username/password login, password reset, and registration |
X509_AUTH_ENABLED | true | X.509 certificate (CAC/PIV) authentication |
SOCIAL_AUTH_ENABLED | true | Social/SSO login (Google, Azure AD, etc.); requires an IdP to also be configured |
OTP_ENABLED | true | One-time password (TOTP) as a required MFA step for username/password login |
WEBAUTHN_ENABLED | false | WebAuthn/passkey as a required MFA step for username/password login |
X509_MFA_ENABLED | false | Require additional MFA (OTP or WebAuthn) after X.509 authentication |
-
Determine which flows to enable
Identify which authentication methods your environment requires. Common configurations:
Environment Recommended configuration CAC-only (no username/password) Disable USERNAME_PASSWORD_AUTH_ENABLED, keepX509_AUTH_ENABLEDUsername/password + OTP only Keep defaults, disable X509_AUTH_ENABLEDandSOCIAL_AUTH_ENABLEDUsername/password + WebAuthn Enable WEBAUTHN_ENABLED, disableOTP_ENABLEDif desiredCAC + MFA Enable X509_MFA_ENABLED(also requiresOTP_ENABLEDorWEBAUTHN_ENABLED) -
Add
realmAuthFlowsto your bundle overrideIn your
uds-bundle.yaml, set the desired authentication flow values:uds-bundle.yaml packages:- name: corerepository: registry.defenseunicorns.com/public/coreref: x.x.x-upstreamoverrides:keycloak:keycloak:values:- path: realmAuthFlowsvalue:USERNAME_PASSWORD_AUTH_ENABLED: trueX509_AUTH_ENABLED: falseSOCIAL_AUTH_ENABLED: falseOTP_ENABLED: trueWEBAUTHN_ENABLED: falseX509_MFA_ENABLED: falseFor clarity and auditability, specifying all settings explicitly is recommended, even settings you are leaving at their defaults.
-
Create and deploy your bundle
Terminal window uds create <path-to-bundle-dir>uds deploy uds-bundle-<name>-<arch>-<version>.tar.zst -
(Optional) Update realm flows on an existing deployment
If the Keycloak realm was already imported, a new
realmAuthFlowsvalue does not update its realm flows. Manually update the uds realm in the Keycloak Admin Console atkeycloak.<admin_domain>. Apply the tab for each primary method or optional MFA method you need to update. For example, to keep only Social/SSO after deploying X.509/CAC and Social/SSO, apply the X.509/CAC tab.For
USERNAME_PASSWORD_AUTH_ENABLED: false:- Open Authentication → Flows → UDS Authentication.
- Expand Username Password Form.
- Set Deny Access to Required.
- Open Authentication → Flows → UDS Reset Credentials and disable Reset Password.
- Open Authentication → Flows → UDS Registration. Leave UDS Registration form enabled if X.509/CAC remains enabled. If X.509/CAC is also disabled, disable UDS Registration form.
For
X509_AUTH_ENABLED: false:- Open Authentication → Flows → UDS Authentication.
- Set X509 Authentication to Disabled.
- Open Authentication → Flows → UDS Registration. Leave UDS Registration form enabled if username/password remains enabled. If username/password is also disabled, disable UDS Registration form.
- Stop the gateway from requesting client certificates as described in Configure the CA truststore.
For
SOCIAL_AUTH_ENABLED: false:- Open Authentication → Flows → UDS Authentication.
- Set IDP Redirector to Disabled.
For
OTP_ENABLED: true:- Open Authentication → Flows → UDS Authentication. In Username/Password Authentication, set the Conditional OTP sub-flow to Required.
- Inside the Conditional OTP sub-flow, set OTP to Required.
- Open Authentication → Required Actions and enable Configure OTP.
For
OTP_ENABLED: false:- Open Authentication → Flows → UDS Authentication.
- Inside the Conditional OTP sub-flow, set OTP to Disabled.
- If WebAuthn is also disabled, set the Conditional OTP sub-flow to Disabled.
For
WEBAUTHN_ENABLED: true:- Open Authentication → Required Actions and enable Webauthn Register.
- Open Authentication → Flows → UDS Authentication. In Username/Password Authentication, set the Conditional OTP sub-flow to Required.
- Inside the Conditional OTP sub-flow, set WebAuthn Authenticator to Required.
For
WEBAUTHN_ENABLED: false:- Open Authentication → Required Actions and disable Webauthn Register.
- Open Authentication → Flows → UDS Authentication.
- Inside the Conditional OTP sub-flow, set WebAuthn Authenticator to Disabled.
- If OTP is also disabled, set the Conditional OTP sub-flow to Disabled.
Verification
Section titled “Verification”Confirm authentication flow changes are applied:
- Navigate to
sso.<domain> - Confirm only the expected login options appear on the login page
- For X.509/CAC: confirm the browser prompts for a client certificate (requires truststore to be configured and a valid certificate installed)
Check Keycloak authentication flow configuration:
In the Keycloak admin UI, navigate to keycloak.<admin_domain> → uds realm → Authentication → Flows and confirm the expected flow steps are enabled or disabled.
Troubleshooting
Section titled “Troubleshooting”Problem: X.509/CAC login fails with OCSP error in airgapped environment
Section titled “Problem: X.509/CAC login fails with OCSP error in airgapped environment”Symptoms: Certificate authentication fails with an OCSP revocation check error. Logs show the OCSP responder is unreachable.
Solution: Configure OCSP fail-open behavior or disable OCSP checking via realmInitEnv.
To allow authentication when the OCSP responder is unreachable (fail-open):
- path: realmInitEnv value: X509_OCSP_FAIL_OPEN: "true"To disable OCSP checking entirely:
- path: realmInitEnv value: X509_OCSP_CHECKING_ENABLED: "false"If your environment uses CRL-based revocation instead of OCSP, configure the CRL path:
- path: realmInitEnv value: X509_CRL_CHECKING_ENABLED: "true" X509_CRL_RELATIVE_PATH: "crls/DODROOTCA3.crl##crls/DODIDCA_81.crl" # Relative to /opt/keycloak/conf; use ## between multiple paths X509_CRL_ABORT_IF_NON_UPDATED: "false" # Set true to fail authentication if CRL is expiredProblem: MFA is not required after enabling WebAuthn or OTP
Section titled “Problem: MFA is not required after enabling WebAuthn or OTP”Symptoms: Users can log in without completing an MFA step.
Solution: Confirm that both the flow toggle and at least one MFA method are enabled. For WebAuthn to work as a required step, WEBAUTHN_ENABLED: true must be set; for OTP, OTP_ENABLED: true. Verify the realm was redeployed after the override was applied.
If redeploying is not possible, use the corresponding OTP or WebAuthn tab in Step 4.
Reference: X.509/CAC with additional MFA
Section titled “Reference: X.509/CAC with additional MFA”If you do need to require an additional factor after CAC authentication, use this configuration in the realmAuthFlows block from step 2 in place of the values shown there, then recreate and deploy the bundle:
- path: realmAuthFlows value: X509_AUTH_ENABLED: true X509_MFA_ENABLED: true OTP_ENABLED: true # At least one MFA method must also be enabled WEBAUTHN_ENABLED: falseX509_MFA_ENABLED: true has no effect unless at least one of OTP_ENABLED or WEBAUTHN_ENABLED is also enabled.
Related documentation
Section titled “Related documentation”- Keycloak: Authentication - upstream reference for Keycloak authentication flow configuration
- Configure the CA truststore - Configure the CA certificate bundle required for X.509/CAC authentication.
- Configure user accounts and security policies - Set password complexity and email verification alongside auth flow configuration.