MFA and passkeys
ulex strong authentication: MFA factors, TOTP, WebAuthn passkeys with clone detection, adaptive MFA policies, the amr and acr claims, headless MFA simulation for agents, and what is never stored.
#What ulex stores
| Factor type | Stored | Never stored |
|---|---|---|
totp | the shared secret, encrypted with the tenant KEK | — |
sms | SHA-256 of the phone number, in target_hint | the phone number |
email | SHA-256 of the address | the address |
webauthn | the credential id and public key | any private key, ever, anywhere |
push | the device registration | — |
backup_code | SHA-256 of each code, one-time | the codes |
secret_encrypted is never serialised to any client. target_hint is a salted SHA-256, so an operator reading the database cannot reconstruct a phone number.
#Passkeys
{
"id": "psk_01M3PSVR5GYASQ2ETPYPC11Y2A",
"object": "passkey",
"user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
"credential_id": "8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mN",
"counter": 0,
"transports": ["internal", "hybrid"],
"aaguid": "adce0002-35bc-c60a-648b-0b25f1f05503",
"device_type": "multi_device",
"backed_up": true,
"name": "MacBook Pro",
"created_at": "2026-09-29T14:42:22.000Z",
"last_used_at": "2026-09-29T14:45:12.000Z"
}| Field | Why it exists |
|---|---|
counter | WebAuthn signature counter. A counter that does not increase indicates a cloned authenticator and ulex rejects the assertion. This is the single most important passkey field. |
aaguid | identifies the authenticator model. A new aaguid on an existing credential_id is suspicious |
backed_up | true when the credential is synced through a platform passkey manager. A behaviour signal for risk, not a rejection |
device_type | single_device credentials do not sync; multi_device do |
transports | usb, nfc, ble, internal, hybrid |
When ulex rejects a cloned passkey it writes authentication.mfa_failed with error_code: "passkey_counter_regression" and suspends the credential pending re-enrolment.
#The auth policy
{
"mfa": {
"mode": "adaptive",
"methods": ["webauthn", "totp", "push"],
"remember_device_days": 30,
"trigger_on_new_device": true,
"trigger_on_ip_change": true,
"trigger_on_high_risk": true
},
"password": {
"min_length": 12,
"require_uppercase": true,
"require_lowercase": true,
"require_number": true,
"require_symbol": true,
"check_breached_passwords": true,
"max_age_days": 365,
"forbid_reuse_count": 5
},
"session": {
"lifetime_seconds": 86400,
"idle_timeout_seconds": 604800,
"reauthenticate_after_seconds": 86400,
"bind_to_ip": false,
"bind_to_user_agent": true,
"cross_app_sso": true
}
}#mfa.mode
| Mode | Behaviour |
|---|---|
optional | challenges users who enrolled a usable TOTP or recovery factor; users without one are not challenged |
required | challenges users who enrolled a usable TOTP or recovery factor; users without one can still sign in |
adaptive | stored but NOT applied; there is no risk engine |
required does not currently require enrollment. ulex has no first-factor enrollment ceremony, so enforcing that for existing users would lock them out with no recovery path. Do not represent this mode as universal MFA enforcement. methods, remember_device_days, and trigger_on_* are also stored but NOT applied.
#password.check_breached_passwords
Compares against a k-anonymity breach corpus: the first five characters of the SHA-1 hash go out, the corpus returns candidates, the comparison happens locally. The password itself never leaves the process. NIST SP 800-63B guidance.
The tenant's check_breached_passwords value controls screening. ULEX_SCREEN_PASSWORDS is the deployment-wide default only when no tenant auth policy exists; a tenant setting overrides it. A match is a warning, not a password refusal.
#The amr and acr claims
amr (authentication methods reference) tells you how the user authenticated:
"amr": ["pwd", "otp", "mfa"],
"amr_details": [
{ "method": "pwd", "acr": "urn:ulex:acr:pwd" },
{ "method": "otp", "acr": "urn:ulex:acr:otp" },
{ "method": "webauthn", "acr": "urn:ulex:acr:mfa", "ts": 1790693112 }
]amr value | Means |
|---|---|
pwd | password |
otp | one-time code, TOTP or email |
sms | SMS |
webauthn | passkey |
pushed | push notification |
mfa | a second factor was satisfied, in addition to the above |
saml | federated through SAML |
oidc | federated through upstream OIDC |
hwk | hardware key |
urn:ulex:amr:simulated | ulex_mint_access_token; not a real authentication |
acr (authentication context class reference) tells you how strong it was:
acr | Meaning |
|---|---|
urn:ulex:acr:pwd | password only |
urn:ulex:acr:otp | password plus one-time code |
urn:ulex:acr:mfa | password plus a second factor |
urn:ulex:acr:phishing-resistant | passkey or hardware key |
urn:ulex:acr:simulated | forged by the simulator |
Your application should branch on acr, not on amr. amr tells you the history; acr tells you whether it was good enough.
export function isPhishingResistant(claims: AccessTokenClaims): boolean {
return claims.acr === "urn:ulex:acr:phishing-resistant" || claims.amr?.includes("webauthn") === true;
}
export function requireMfa(claims: AccessTokenClaims): void {
if (claims.acr !== "urn:ulex:acr:mfa" && claims.acr !== "urn:ulex:acr:phishing-resistant") {
throw new Error("this action requires MFA");
}
}#Demanding a level
GET /api/v1/oauth2/authorize?...&acr_values=urn:ulex:acr:mfa&max_age=0If the current session does not meet the demand, the response is 401 step_up_required (not 403), retryable: false, with hint: "Re-authenticate with acr_values=urn:ulex:acr:mfa."
max_age=0 forces reauthentication regardless of session age. Combine it with acr_values for sensitive operations.
#Simulating MFA as an agent
You never touch an authenticator app. Three calls.
{ "name": "ulex_simulate_mfa", "arguments": { "mode": "challenge", "email": "dana@acme.example", "method": "webauthn" } }{
"challenge_id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ",
"armed": true,
"methods": ["totp", "webauthn", "push"],
"method": "webauthn",
"expires_at": "2026-09-29T14:55:12.000Z",
"code": "418902"
}Now attempt the login. It will be challenged, not completed:
{ "name": "ulex_simulate_login", "arguments": { "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B", "email": "dana@acme.example" } }{
"session_id": null,
"grant_id": null,
"outcome": "challenge",
"stage": "mfa",
"error": {
"type": "authentication_error",
"code": "mfa_required",
"message": "A second factor is required before this authorization can complete.",
"request_id": "req_01M3PSX7B2KQ4V6W8Y0Z1A3B5C",
"retryable": false,
"hint": "Present the challenge to the user, or satisfy it with ulex_simulate_mfa { mode: 'satisfy' }."
},
"amr": ["pwd"],
"acr": null
}Satisfy it and log in again:
{ "name": "ulex_simulate_mfa", "arguments": { "mode": "satisfy", "challenge_id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ" } }{ "satisfied": true, "amr": ["pwd", "otp", "mfa"] }{ "name": "ulex_simulate_login", "arguments": { "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B", "email": "dana@acme.example" } }{
"session_id": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
"grant_id": "grt_01M3PSVGBGJT1ZXC840F2B3NXJ",
"outcome": "success",
"stage": "complete",
"amr": ["pwd", "otp", "mfa"],
"acr": "urn:ulex:acr:mfa",
"code": "ac_8Kq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
"code_expires_at": "2026-09-29T14:46:12.000Z"
}The resulting token's amr contains mfa and acr is urn:ulex:acr:mfa. That is the assertion you want to make in a test.
#Testing the failure path
{ "name": "ulex_simulate_mfa", "arguments": { "mode": "challenge", "email": "dana@acme.example", "method": "totp" } }{ "name": "ulex_simulate_mfa", "arguments": { "mode": "fail", "challenge_id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ" } }{
"satisfied": false,
"outcome": "failure",
"error": { "type": "authentication_error", "code": "invalid_otp", "message": "That code is not correct.", "retryable": false },
"audit_action": "authentication.mfa_failed",
"attempts_remaining": 2
}attempts_remaining: 2 matters: ulex locks the challenge after 3 failures, and after 5 locked challenges it requires a fresh login_hint rather than a silent retry. Implement the lockout in your client or you will hammer a challenge that is already dead.
#Enrolling a user with MFA
mock_sso connections can seed enrollment:
{
"name": "ulex_create_connection",
"arguments": {
"name": "Acme SSO",
"config": {
"strategy": "mock_sso",
"mock": {
"seed_users": [
{ "email": "dana@acme.example", "first_name": "Dana", "mfa_enrolled": true, "status": "active" },
{ "email": "pat@acme.example", "first_name": "Pat", "mfa_enrolled": false, "status": "active" }
]
}
}
}
}mfa_enrolled: true means the user is challenged. false means they are not, unless the policy is required or adaptive with no factor enrolled.
curl -sS "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S/mfa-factors" -H "Authorization: Bearer $ULEX_API_KEY" | jq
curl -sS "$BASE/users/usr_01M3PSV9GRT8GQGEG686AR1W9S/passkeys" -H "Authorization: Bearer $ULEX_API_KEY" | jq#What is audited
| Action | When |
|---|---|
authentication.challenge | any step-up or MFA challenge was raised |
authentication.mfa_challenge | an MFA prompt was presented |
authentication.mfa_failed | a wrong or missing code, or a passkey counter regression |
authentication.succeeded | carries metadata.amr and metadata.acr |
curl -sS -G "$BASE/audit-events" -H "Authorization: Bearer $ULEX_API_KEY" \
--data-urlencode 'action_prefix=authentication.' \
--data-urlencode 'since=2026-09-29T00:00:00.000Z' | jq '.data[] | {action, outcome, error_code, amr: .metadata.amr}'#Checklist before you go live
- [ ]
acr_valuesis checked in your application, not justamr. - [ ]
urn:ulex:acr:phishing-resistantis required for the highest-risk operations, noturn:ulex:acr:mfa. - [ ] A failed MFA attempt does not retry automatically.
- [ ] The lockout counter is respected.
- [ ] Passkey counter regression is handled as credential compromise, not as a bug.
- [ ]
check_breached_passwordsis on for any tenant usingpasswordorldap. - [ ] A recovery path exists that does not let an agent bypass MFA.
ulex_mint_access_tokenwrites no authentication event and itsamrisurn:ulex:amr:simulated; if your app accepts that claim, a compromised API key becomes a full account takeover.