Skip to content

Configure user accounts and security policies

You’ll configure user account behavior for your UDS Core Keycloak realm: setting password complexity policy, enabling email verification, using email as the username, and extending the UDS security hardening allow lists for protocol mappers and client scopes. All settings in this guide use realmInitEnv bundle overrides — no image rebuild required.

  • UDS Core deployed
  • UDS CLI installed

All settings in this guide are applied via realmInitEnv in a bundle override. These values are applied only during initial realm import. If Keycloak is already running, Keycloak must be fully torn down and redeployed for changes to take effect.

SettingDefaultDescription
EMAIL_AS_USERNAMEfalseUse the user’s email address as their Keycloak username
EMAIL_VERIFICATION_ENABLEDfalseRequire users to verify their email before accessing the realm
PASSWORD_POLICYSee defaultKeycloak password policy string
SECURITY_HARDENING_ADDITIONAL_PROTOCOL_MAPPERSunsetAdditional protocol mappers to allow beyond the UDS defaults
SECURITY_HARDENING_ADDITIONAL_CLIENT_SCOPESunsetAdditional client scopes to allow beyond the UDS defaults
  1. Configure email settings

    By default, Keycloak uses a separate username field for login. Set EMAIL_AS_USERNAME: "true" if your users authenticate with their email address instead of a distinct username:

    uds-bundle.yaml
    packages:
    - name: core
    repository: registry.defenseunicorns.com/public/core
    ref: x.x.x-upstream
    overrides:
    keycloak:
    keycloak:
    values:
    - path: realmInitEnv
    value:
    EMAIL_AS_USERNAME: "true"
    EMAIL_VERIFICATION_ENABLED: "true"
    SettingEffect when true
    EMAIL_AS_USERNAMEThe username field on the login and registration form is replaced by an email field; email becomes the unique identifier
    EMAIL_VERIFICATION_ENABLEDUsers receive a verification email after registration and must click the link before they can log in
  2. Set a custom password policy

    UDS Core ships with a default password policy aligned with STIG requirements:

    hashAlgorithm(pbkdf2-sha256) and forceExpiredPasswordChange(60) and specialChars(2) and digits(1) and lowerCase(1) and upperCase(1) and passwordHistory(5) and length(15) and notUsername(undefined)

    This default enforces:

    • Password hashing with PBKDF2-SHA256
    • Passwords expire every 60 days
    • At least 2 special characters, 1 digit, 1 lowercase, 1 uppercase
    • Last 5 passwords cannot be reused
    • Minimum length of 15 characters
    • Password cannot contain the username

    To override, set PASSWORD_POLICY to a Keycloak policy string:

    uds-bundle.yaml
    packages:
    - name: core
    repository: registry.defenseunicorns.com/public/core
    ref: x.x.x-upstream
    overrides:
    keycloak:
    keycloak:
    values:
    - path: realmInitEnv
    value:
    PASSWORD_POLICY: "hashAlgorithm(pbkdf2-sha256) and forceExpiredPasswordChange(90) and specialChars(1) and digits(1) and lowerCase(1) and upperCase(1) and length(12) and notUsername(undefined)"

    See the Keycloak password policy documentation for the full list of available policy types.

  3. (Optional) Extend security hardening allow lists

    UDS Core enforces a default allow list of protocol mappers and client scopes for all packages managed by the UDS Operator. If your packages require additional mappers or scopes beyond the defaults, add them here:

    uds-bundle.yaml
    packages:
    - name: core
    repository: registry.defenseunicorns.com/public/core
    ref: x.x.x-upstream
    overrides:
    keycloak:
    keycloak:
    values:
    - path: realmInitEnv
    value:
    SECURITY_HARDENING_ADDITIONAL_PROTOCOL_MAPPERS: "oidc-hardcoded-claim-mapper, saml-hardcode-attribute-mapper"
    SECURITY_HARDENING_ADDITIONAL_CLIENT_SCOPES: "role_list"

    Multiple values are comma-separated. These are appended to the UDS defaults — they do not replace them.

  4. Create and deploy your bundle

    Terminal window
    uds create <path-to-bundle-dir>
    uds deploy uds-bundle-<name>-<arch>-<version>.tar.zst

    If Keycloak is already running with an existing realm, Keycloak must be fully torn down and redeployed for realmInitEnv settings to take effect.

Verify password policy:

In the Keycloak Admin Console (keycloak.<admin_domain>), switch to the uds realm and navigate to Realm SettingsSecurity DefensesPassword Policy. Confirm the policy entries match your configuration.

Verify email-as-username:

Navigate to sso.<domain> and confirm the login form shows an email field rather than a username field.

Verify email verification:

Register a new test user and confirm a verification email is dispatched before the account can be used to log in.

Verify security hardening allow lists:

In the Keycloak Admin Console, navigate to Realm SettingsClient PoliciesProfilesUDS Client Profileuds-operator-permissions executor. Confirm your additional mappers and scopes appear in the configuration.

Problem: Password policy changes are not reflected in the admin UI

Section titled “Problem: Password policy changes are not reflected in the admin UI”

Symptoms: The Keycloak admin UI shows the old password policy after redeploy.

Solution: realmInitEnv settings are applied only during initial realm import. To update the policy on a live instance without redeploying, configure it manually in the Keycloak Admin Console under Realm SettingsSecurity DefensesPassword Policy.

Problem: EMAIL_VERIFICATION_ENABLED has no effect (users are not receiving emails)

Section titled “Problem: EMAIL_VERIFICATION_ENABLED has no effect (users are not receiving emails)”

Symptoms: Users register but do not receive a verification email.

Solution: Confirm SMTP is configured in the Keycloak Admin Console under Realm SettingsEmail. Without a valid SMTP server, Keycloak cannot send verification emails regardless of the EMAIL_VERIFICATION_ENABLED setting.

Problem: Package deployment fails after adding security hardening entries

Section titled “Problem: Package deployment fails after adding security hardening entries”

Symptoms: The UDS Operator rejects a Package CR that includes a protocol mapper or client scope.

Solution: Confirm the mapper or scope name is spelled correctly. Also confirm Keycloak was fully redeployed after the realmInitEnv change was applied — these settings only take effect on initial realm import.

These guides and concepts may be useful to explore next: