Identity Configuration

Configuration for the OSS identity runtime. This page documents the actual spring.auth.* and contexa.identity.statemachine.* properties used by the current Contexa codebase and shows where runtime classes such as AuthUrlProvider, MfaFlowUrlRegistry, IdentityDslRegistry, MfaDslConfigurerImpl, and SessionStateConfigurer consume them.

Auth Context Properties

AuthContextProperties is bound to the spring.auth prefix. It controls authentication state selection, token transport, token issuer mode, URL groups, MFA runtime defaults, and token lifecycle.

Core Authentication Settings

PropertyTypeDefaultDescription
spring.auth.state-typeStateTypeOAUTH2Selects the default state mode. Current enum values are OAUTH2 and SESSION.
spring.auth.token-transport-typeTokenTransportTypeHEADERControls how tokens are transported. Current enum values are COOKIE, HEADER, and HEADER_COOKIE.
spring.auth.token-issuerTokenIssuerINTERNALSelects whether Contexa issues tokens itself or expects an external authorization server. Current enum values are INTERNAL and AUTHORIZATION_SERVER.
spring.auth.factor-selection-typeFactorSelectionTypeSELECTControls whether MFA factor choice is explicitly presented or automatically selected. Current enum values are AUTO and SELECT.
spring.auth.access-token-validitylong3600000Access token validity in milliseconds.
spring.auth.refresh-token-validitylong604800000Refresh token validity in milliseconds.
spring.auth.refresh-rotate-thresholdlong43200000Threshold after which refresh-token rotation is triggered on use.
spring.auth.enable-refresh-tokenbooleantrueEnables refresh token issuance.
spring.auth.allow-multiple-loginsbooleanfalseAllows multiple concurrent active logins for the same principal.
spring.auth.max-concurrent-loginsint3Concurrent login ceiling when multiple logins are allowed.
spring.auth.cookie-securebooleantrueMarks authentication cookies as secure by default.
spring.auth.token-persistenceStringmemoryFrontend token persistence mode passed to login and MFA pages. Current OSS client modes are memory, localstorage, and sessionstorage.
spring.auth.token-prefixStringBearer Authorization header prefix.
spring.auth.roles-claimStringrolesJWT claim name used for roles.
spring.auth.scopes-claimStringscopesJWT claim name used for scopes.
spring.auth.oauth2-csrfbooleanfalseToggles CSRF protection for OAuth2-oriented endpoints.
YAML
spring:
  auth:
    state-type: oauth2
    token-transport-type: header
    token-issuer: internal
    factor-selection-type: select
    access-token-validity: 3600000
    refresh-token-validity: 604800000
    refresh-rotate-threshold: 43200000
    enable-refresh-token: true
    allow-multiple-logins: false
    max-concurrent-logins: 3
    cookie-secure: true
    token-persistence: memory
    token-prefix: "Bearer "
    roles-claim: roles
    scopes-claim: scopes
    oauth2-csrf: false

Related runtime references: Authentication, Adaptive MFA, and State Management.

URL Configuration Groups

spring.auth.urls is consumed by AuthUrlProvider. For MFA flows, MfaFlowUrlRegistry creates per-flow providers so named flows can safely apply custom prefixes without mutating shared global state.

Single Authentication URLs

PropertyDefaultDescription
spring.auth.urls.single.form-login-processing/loginDefault processing endpoint for non-MFA form login.
spring.auth.urls.single.form-login-page/loginDefault page for non-MFA form login.
spring.auth.urls.single.rest-login-processing/api/loginDefault processing endpoint for non-MFA REST login.
spring.auth.urls.single.login-failure/login?errorFailure redirect for non-MFA flows.
spring.auth.urls.single.login-success/Success redirect for non-MFA flows.
spring.auth.urls.single.logout-page/logoutLogout page for single-factor flows.
spring.auth.urls.single.ott.request-email/login/ottSingle-factor OTT request page.
spring.auth.urls.single.ott.code-generation/ott/generateSingle-factor OTT code generation endpoint.
spring.auth.urls.single.ott.code-sent/login/ott/sentSingle-factor OTT sent page.
spring.auth.urls.single.ott.challenge/login/ott/verifySingle-factor OTT verification page.
spring.auth.urls.single.ott.login-processing/login/ottSingle-factor OTT verification endpoint.
spring.auth.urls.single.ott.login-failure/login/ott?errorSingle-factor OTT failure page.
spring.auth.urls.single.passkey.login-page/login/webauthnSingle-factor passkey login page.
spring.auth.urls.single.passkey.login-processing/login/webauthnSingle-factor passkey verification endpoint.
spring.auth.urls.single.passkey.login-failure/login/webauthn?errorSingle-factor passkey failure page.
spring.auth.urls.single.passkey.assertion-options/webauthn/authenticate/optionsPasskey assertion options endpoint.
spring.auth.urls.single.passkey.registration-options/webauthn/register/optionsPasskey registration options endpoint.
spring.auth.urls.single.passkey.registration-processing/webauthn/registerPasskey registration processing endpoint.

MFA URL Groups

PropertyDefaultDescription
spring.auth.urls.primary.form-login-processing/mfa/loginPrimary form-processing URL used inside MFA flows.
spring.auth.urls.primary.form-login-page/mfa/loginPrimary form page used inside MFA flows.
spring.auth.urls.primary.rest-login-processing/api/mfa/loginPrimary REST login endpoint used inside MFA flows.
spring.auth.urls.primary.login-failure/login?errorPrimary failure redirect.
spring.auth.urls.primary.login-success/Primary success redirect.
spring.auth.urls.primary.logout-page/logoutPrimary logout page.
spring.auth.urls.mfa.select-factor/mfa/select-factorMFA factor selection page.
spring.auth.urls.mfa.success/mfa/successMFA success page.
spring.auth.urls.mfa.failure/mfa/failureMFA failure page.
spring.auth.urls.mfa.cancel/mfa/cancelMFA cancellation endpoint/page.
spring.auth.urls.mfa.status/mfa/statusMFA status endpoint.
spring.auth.urls.mfa.request-ott-code/mfa/request-ott-codeOTT code request endpoint.
spring.auth.urls.mfa.config/api/mfa/configMFA config endpoint used by the page generator and client code.
spring.auth.urls.factors.ott.request-code-ui/mfa/ott/request-code-uiOTT request page.
spring.auth.urls.factors.ott.code-generation/mfa/ott/generate-codeOTT code generation endpoint.
spring.auth.urls.factors.ott.code-sent/mfa/ott/code-sentOTT code-sent page.
spring.auth.urls.factors.ott.challenge-ui/mfa/challenge/ottOTT challenge page.
spring.auth.urls.factors.ott.login-processing/login/mfa-ottOTT login-processing endpoint.
spring.auth.urls.factors.ott.default-failure/mfa/challenge/ott?error=trueDefault OTT failure redirect.
spring.auth.urls.factors.ott.single-ott-request-email/loginOttLegacy single-OTT request page path retained by OttUrls.
spring.auth.urls.factors.ott.single-ott-code-generation/login/ott/generateLegacy single-OTT generation path retained by OttUrls.
spring.auth.urls.factors.ott.single-ott-challenge/loginOttVerifyCodeLegacy single-OTT challenge path retained by OttUrls.
spring.auth.urls.factors.ott.single-ott-sent/ott/sentLegacy single-OTT sent page path retained by OttUrls.
spring.auth.urls.factors.passkey.rp-idlocalhostDefault passkey relying-party ID.
spring.auth.urls.factors.passkey.rp-namecontexa-identityDefault passkey relying-party name.
spring.auth.urls.factors.passkey.allowed-originsnullComma-separated allowed origins. When unset, the passkey builder falls back to http://localhost:{server.port}.
spring.auth.urls.factors.passkey.login-processing/login/mfa-webauthnPasskey authentication endpoint for MFA mode.
spring.auth.urls.factors.passkey.challenge-ui/mfa/challenge/passkeyPasskey challenge page.
spring.auth.urls.factors.passkey.registration-processing/webauthn/registerPasskey registration endpoint.
spring.auth.urls.factors.passkey.assertion-options/webauthn/authenticate/optionsPasskey assertion options endpoint.
spring.auth.urls.factors.passkey.registration-options/webauthn/register/optionsPasskey registration options endpoint.
spring.auth.urls.factors.recovery-code-login-processing/login/recovery/verifyRecovery-code verification endpoint.
spring.auth.urls.factors.recovery-code-challenge-ui/mfa/challenge/recoveryRecovery-code challenge page.

Runtime consumers: AuthUrlProvider resolves these paths, while MfaFlowUrlRegistry creates per-flow providers so named MFA flows can safely use different prefixes.

Token Issuer Settings

spring.auth.internal and spring.auth.oauth2 hold the two token-issuer configurations selected by spring.auth.token-issuer.

Internal JWT Endpoints

PropertyDefaultDescription
spring.auth.internal.login-uri/api/loginInternal JWT login endpoint.
spring.auth.internal.logout-uri/logoutInternal logout endpoint.
spring.auth.internal.refresh-uri/api/refreshInternal refresh endpoint.

OAuth2 / Authorization-Server Settings

PropertyDefaultDescription
spring.auth.oauth2.client-iddefault-clientOAuth2 client identifier.
spring.auth.oauth2.client-secret173f8245-5f7d-4623-a612-aa0c68f6da4aDefault client secret declared by OAuth2TokenSettings. Override it in real deployments.
spring.auth.oauth2.issuer-urihttp://localhost:9000Issuer base URI.
spring.auth.oauth2.token-endpoint/oauth2/tokenToken endpoint path.
spring.auth.oauth2.scopereadDefault scope requested by the runtime.
spring.auth.oauth2.redirect-urihttp://localhost:8080Post-authorization redirect URI.
spring.auth.oauth2.authorized-urinullOptional post-authorization redirect override.
spring.auth.oauth2.jwk-key-store-pathnullPath to the JWK keystore.
spring.auth.oauth2.jwk-key-store-passwordnullKeystore password.
spring.auth.oauth2.jwk-key-aliasnullKey alias inside the keystore.
spring.auth.oauth2.jwk-key-passwordnullKey password override.
YAML
spring:
  auth:
    token-issuer: authorization_server
    internal:
      login-uri: /api/login
      logout-uri: /logout
      refresh-uri: /api/refresh
    oauth2:
      client-id: default-client
      client-secret: replace-me
      issuer-uri: http://localhost:9000
      token-endpoint: /oauth2/token
      scope: read
      redirect-uri: http://localhost:8080

MFA Runtime Settings

spring.auth.mfa is bound to MfaSettings. It controls challenge lifecycles, retry policy, repository selection, factor delivery defaults, and diagnostics. These defaults are consumed by MFA filters, handlers, and state-machine-aware request handling code.

PropertyTypeDefaultDescription
spring.auth.mfa.session-timeout-mslong600000Overall MFA session timeout.
spring.auth.mfa.challenge-timeout-mslong300000Per-challenge timeout window.
spring.auth.mfa.inactivity-timeoutlong900000Idle-time cutoff for MFA state.
spring.auth.mfa.cache-ttllong300000TTL for MFA runtime cache entries.
spring.auth.mfa.session-refresh-interval-mslong30000Refresh cadence for active MFA sessions.
spring.auth.mfa.state-machine-timeout-mslong10000Timeout budget for state-machine-aware MFA handlers.
spring.auth.mfa.max-retry-attemptsint5Maximum verification retries before lockout logic applies.
spring.auth.mfa.account-lockout-duration-mslong900000Duration of MFA lockout after retry exhaustion.
spring.auth.mfa.minimum-delay-mslong500Minimum timing floor used to reduce response timing variance.
spring.auth.mfa.device-remember-duration-mslong2592000000Remember-device duration.
spring.auth.mfa.otp-token-validity-secondsint300OTP validity window.
spring.auth.mfa.otp-token-lengthint6OTP code length.
spring.auth.mfa.sms-resend-interval-secondsint60SMS resend throttle.
spring.auth.mfa.email-resend-interval-secondsint120Email resend throttle.
spring.auth.mfa.state-machine-pool-sizeint100Legacy MFA state-machine pool size setting preserved by MfaSettings.
spring.auth.mfa.state-machine-cache-ttl-mslong300000Legacy MFA state-machine cache TTL preserved by MfaSettings.
spring.auth.mfa.circuit-breaker-failure-thresholdint5Failure threshold before the MFA circuit breaker opens.
spring.auth.mfa.circuit-breaker-timeout-secondsint30Open-state timeout for the MFA circuit breaker.
spring.auth.mfa.detailed-logging-enabledbooleanfalseEnables verbose MFA diagnostics.
spring.auth.mfa.metrics-enabledbooleantrueEnables MFA metrics.
spring.auth.mfa.audit-logging-enabledbooleantrueEnables MFA audit logging.
spring.auth.mfa.session-storage-typeStringhttp-sessionPrimary MFA session repository label.
spring.auth.mfa.auto-select-repositorybooleanfalseEnables automatic repository selection.
spring.auth.mfa.repository-priorityStringredis,memory,http-sessionRepository priority order string.
spring.auth.mfa.fallback-repository-typeStringhttp-sessionFallback repository label.

MFA Repository Settings

PropertyDefaultDescription
spring.auth.mfa.http-session.enabledtrueEnables the HTTP-session-backed MFA repository.
spring.auth.mfa.http-session.create-session-if-not-existstrueCreates an HTTP session on demand.
spring.auth.mfa.http-session.session-attribute-nameMFA_SESSION_IDAttribute name used to store the MFA session identifier.
spring.auth.mfa.redis.enabledtrueEnables the Redis-backed MFA repository.
spring.auth.mfa.redis.key-prefixmfa:session:Redis key prefix for MFA sessions.
spring.auth.mfa.redis.cookie-nameMFA_SIDCookie carrying the Redis-backed MFA session identifier.
spring.auth.mfa.redis.secure-cookietrueMarks the MFA session cookie as secure.
spring.auth.mfa.redis.http-only-cookietrueMarks the MFA session cookie as HTTP-only.
spring.auth.mfa.redis.same-siteStrictSameSite cookie attribute.
spring.auth.mfa.redis.connection-timeout3000Redis connection timeout.
spring.auth.mfa.redis.max-retries3Redis retry limit.
spring.auth.mfa.memory.enabledtrueEnables the in-memory MFA repository.
spring.auth.mfa.memory.cleanup-interval-minutes5Cleanup interval for in-memory MFA sessions.
spring.auth.mfa.memory.max-sessions10000Maximum number of in-memory MFA sessions.
spring.auth.mfa.memory.enable-metricstrueEnables repository metrics for the in-memory backend.

MFA Factor Settings

PropertyDefaultDescription
spring.auth.mfa.sms-factor.providerdefaultSMS provider identifier.
spring.auth.mfa.sms-factor.template-idmfa_sms_templateSMS template identifier.
spring.auth.mfa.sms-factor.max-daily-attempts10Daily SMS delivery cap.
spring.auth.mfa.sms-factor.enabledtrueEnables SMS MFA factor support.
spring.auth.mfa.email-factor.from-addressnoreply@company.comSender address for email OTP messages.
spring.auth.mfa.email-factor.template-idmfa_email_templateEmail template identifier.
spring.auth.mfa.email-factor.max-daily-attempts5Daily email delivery cap.
spring.auth.mfa.email-factor.enabledtrueEnables email MFA factor support.
YAML
spring:
  auth:
    mfa:
      session-timeout-ms: 600000
      challenge-timeout-ms: 300000
      max-retry-attempts: 5
      repository-priority: redis,memory,http-session
      redis:
        enabled: true
        key-prefix: mfa:session:
        cookie-name: MFA_SID
      memory:
        enabled: true
        max-sessions: 10000
      sms-factor:
        enabled: true
        provider: default
      email-factor:
        enabled: true
        from-address: noreply@company.com

State Machine Properties

StateMachineProperties is bound to contexa.identity.statemachine. It controls the MFA state machine runtime used by the identity module and related filters and handlers.

Core State Machine Settings

PropertyTypeDefaultDescription
contexa.identity.statemachine.enabledbooleantrueMaster switch for the MFA state machine runtime.
contexa.identity.statemachine.operation-timeout-secondsint10Timeout budget for state machine operations.
contexa.identity.statemachine.circuit-breaker.failure-thresholdint5Failure threshold before the circuit breaker opens.
contexa.identity.statemachine.circuit-breaker.timeout-secondsint30Open-state timeout for the circuit breaker.
contexa.identity.statemachine.circuit-breaker.half-open-requestsint3Requests allowed while half-open.

Pool, Persistence, Cache, and Events

PropertyDefaultDescription
contexa.identity.statemachine.pool.core-size10Core state-machine executor size.
contexa.identity.statemachine.pool.max-size50Maximum state-machine executor size.
contexa.identity.statemachine.pool.keep-alive-time10Keep-alive time for pooled workers.
contexa.identity.statemachine.pool.expansion-threshold0.8Expansion threshold for worker scaling.
contexa.identity.statemachine.pool.shrink-threshold0.2Shrink threshold for worker scaling.
contexa.identity.statemachine.persistence.typememoryPersistence backend label.
contexa.identity.statemachine.persistence.enable-fallbacktrueEnables fallback persistence.
contexa.identity.statemachine.persistence.ttl-minutes30Persistence TTL in minutes.
contexa.identity.statemachine.persistence.enable-compressiontrueEnables compressed persistence payloads.
contexa.identity.statemachine.persistence.compression-threshold1024Compression threshold in bytes.
contexa.identity.statemachine.cache.max-size1000In-memory cache size for state-machine snapshots.
contexa.identity.statemachine.cache.ttl-minutes5Cache TTL in minutes.
contexa.identity.statemachine.cache.enable-warmupfalseEnables cache warmup on startup.
contexa.identity.statemachine.events.enabledtrueEnables state-machine event publishing.
contexa.identity.statemachine.events.typelocalEvent transport type.
contexa.identity.statemachine.events.batch-size100Event batch size.
contexa.identity.statemachine.events.batch-interval-ms100Event batch interval.
contexa.identity.statemachine.events.backpressure-threshold1000Backpressure threshold.

MFA, Redis, and Distributed Lock

PropertyDefaultDescription
contexa.identity.statemachine.mfa.enable-metricstrueEnables state-machine MFA metrics.
contexa.identity.statemachine.mfa.max-retries3Retry ceiling used by the state machine.
contexa.identity.statemachine.mfa.session-timeout-minutes30Session timeout in minutes.
contexa.identity.statemachine.mfa.max-concurrent-sessions1000Concurrent state-machine session ceiling.
contexa.identity.statemachine.mfa.transition-timeout-seconds30Transition timeout per state change.
contexa.identity.statemachine.redis.enabledfalseEnables Redis-backed state-machine storage.
contexa.identity.statemachine.redis.ttl-minutes30Redis TTL in minutes.
contexa.identity.statemachine.redis.key-prefixmfa:statemachine:Redis key prefix for state-machine entries.
contexa.identity.statemachine.redis.connection-timeout-ms2000Redis connection timeout.
contexa.identity.statemachine.redis.command-timeout-ms1000Redis command timeout.
contexa.identity.statemachine.distributed-lock.enabledtrueEnables distributed locking around state transitions.
contexa.identity.statemachine.distributed-lock.timeout-seconds10Distributed lock timeout.
contexa.identity.statemachine.distributed-lock.max-retry-attempts3Retry ceiling for lock acquisition.
contexa.identity.statemachine.distributed-lock.retry-interval-ms100Retry interval for lock acquisition.
contexa.identity.statemachine.distributed-lock.enable-deadlock-detectiontrueEnables deadlock detection for distributed locking.
YAML
contexa:
  identity:
    statemachine:
      enabled: true
      operation-timeout-seconds: 10
      pool:
        core-size: 10
        max-size: 50
      persistence:
        type: memory
        ttl-minutes: 30
      events:
        enabled: true
        type: local
      mfa:
        max-retries: 3
        session-timeout-minutes: 30
      distributed-lock:
        enabled: true
        timeout-seconds: 10

Related runtime references: Identity DSL, Authentication, Adaptive MFA, and State Management.