SAML issues
Diagnosing ulex SAML: the seven failure modes, what each means, the verification checklist, certificate rotation, clock skew, attribute mapping, replay, and a headless way to reproduce a customer's IdP behaviour.
#Start here
BASE="https://ulexid.com/api/v1"
AUTH="Authorization: Bearer $ULEX_API_KEY"
# 1. Does the connection validate?
curl -sS -X POST "$BASE/connections/$CON_ID/verify" -H "$AUTH" \
| jq '{valid, failing: [.checks[] | select(.status == "failed")] }'
# 2. What happened on the last real attempt?
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '{state, last_auth_at, last_auth_result, last_auth_error}'
# 3. Where did the attempts die?
curl -sS -G "$BASE/connections/$CON_ID/auth-attempts?limit=10" -H "$AUTH" \
| jq '.data[] | {outcome, stage, error_code, error_message, started_at}'stage tells you which half of the problem you have:
stage | Meaning | Whose problem |
|---|---|---|
initiated | rejected before any redirect | ulex's configuration |
redirected | the IdP would not accept the AuthnRequest | the customer's IdP |
callback | the Response arrived and was rejected | signature, Destination, clock, replay |
validated | the assertion verified; now mapping to a user | allow_create, join policy |
provisioned | JIT creation or linking failed | directory data |
mfa | waiting on a second factor | policy |
#saml_signature_invalid
The most common SAML failure, and the one that appears suddenly, usually about a year in.
| Cause | Tell |
|---|---|
| the IdP rotated its certificate and ulex has the old one | certificate parses passes but the signature does not verify — both certs parse, so only the signature can tell them apart |
| the IdP is signing with a different certificate than the one in its metadata | your metadata fetch and your connection disagree |
| the assertion is signed with an algorithm the connection does not allow | signature algorithm reports the algorithm, but ulex verifies whatever the IdP signed with — a mismatch shows up as saml_signature_invalid, not as a failed check |
Diagnose
curl -sS -X POST "$BASE/connections/$CON_ID/verify" -H "$AUTH" | jq '.checks'
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq -r '.config.saml.x509_certificate' | head -1Compare that certificate against the one in the customer's IdP admin console. If they differ, you have found it.
Fix
curl -sS -X PATCH "$BASE/connections/$CON_ID" -H "$AUTH" -H "Content-Type: application/json" \
-d '{"config":{"strategy":"saml","saml":{ …the full current config, with the new "x509_certificate"… }}}' | jq -r .state
curl -sS -X POST "$BASE/connections/$CON_ID/verify" -H "$AUTH" | jq -r .valid
curl -sS -X POST "$BASE/connections/$CON_ID/activate" -H "$AUTH" | jq -r .stateThe connection is unusable between the patch and the activate. Ask the customer to serve both certificates during an overlap — Okta and Entra both support it, and it removes the window entirely.
PATCH /connections/{id} replaces the whole config object. It does not deep-merge. Read the current config, change the one field, send it all back. Sending a partial config.saml silently drops the other 25 fields and the connection stops validating.
#saml_response_invalid
| Cause | Tell |
|---|---|
| the Response is not well-formed XML | check for a truncated base64 payload |
Destination does not equal the ACS URL | the IdP is posting to a stale URL from before a migration |
the NameID format is not the one the connection declares | the customer changed their app's Name ID format |
Diagnose
# What does ulex believe the ACS URL is?
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '{acs: .config.saml.acs_url, allowed: .config.saml.acs_allowed_urls, format: .config.saml.name_id_format}'# What did the customer send? Decode it.
echo "$SAML_RESPONSE" | base64 -d | xmllint --format - | head -20<Response ID="_aH0mN…" Version="2.0" IssueInstant="2026-09-29T14:45:12Z"
Destination="https://app.example.com/acs"
InResponseTo="_4Kq9WmB2yLt7NxZ…">
<Issuer>https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7</Issuer>Destination here must equal the connection's ACS URL exactly. If the customer moved their app, they must update their IdP app; you cannot configure around it.
#saml_acs_mismatch
InResponseTo does not match an outstanding AuthnRequest, or the ACS URL is not in acs_allowed_urls.
| Situation | Fix |
|---|---|
IdP-initiated login with no InResponseTo | expected and allowed. ulex handles unsolicited responses on /saml/sso |
a genuine SP-initiated flow with a mismatched InResponseTo | the customer is posting a stale response, usually after an SP migration |
| the ACS URL is not allowed | add it to acs_allowed_urls, max 20. Do not add a wildcard |
| ulex restarted between the AuthnRequest and the ACS | the outstanding-request table has a 5-minute TTL; a flow longer than that is not supported |
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '.config.saml.acs_allowed_urls'#saml_clock_skew
NotOnOrAfter is outside allowed_clock_skew_seconds (default 120, max 600).
{
"error": {
"code": "saml_clock_skew",
"message": "The assertion NotOnOrAfter 2026-09-29T14:45:12Z is 4 minutes 12 seconds in the past. Allowed skew: 120s.",
"retryable": false,
"hint": "Synchronise the IdP's clock, or raise config.saml.allowed_clock_skew_seconds to at most 600."
}
}Diagnose. Four minutes of skew is a real NTP problem, not noise. Ask the customer to fix it.
If you must bridge it, raise the tolerance, and put a calendar reminder to lower it:
curl -sS -X PATCH "$BASE/connections/$CON_ID" -H "$AUTH" -H "Content-Type: application/json" \
-d '{"config":{"strategy":"saml","saml":{ …, "allowed_clock_skew_seconds": 300 }}}'600 seconds is a hard ceiling. A larger skew is an outage, not a tolerance problem.
#saml_replay_detected
The Assertion/@ID has already been consumed.
Two causes, one symptom:
| Cause | Tell |
|---|---|
| a genuine IdP retry after a lost HTTP response | the first attempt succeeded and created a session; the retry is redundant and safe to ignore |
| an actual replay attack | the same assertion is being posted twice, minutes or hours apart |
Distinguish them by timing and by whether the first attempt succeeded:
curl -sS -G "$BASE/connections/$CON_ID/auth-attempts?outcome=failure&limit=10" -H "$AUTH" \
| jq '.data[] | {stage, error_code, started_at, duration_ms}'An assertion is consumed exactly once. That is the whole defence; there is no tolerance setting, and there should not be.
#saml_nameid_mismatch
The NameID did not resolve to a user and the policy does not allow creating one.
ulex resolves in this order:
external_id— fromattribute_mapping.external_id, matched againstuser.external_idemail— fromattribute_mapping.email, matched againstuser.email- a user already provisioned from the linked directory
- create, if
allow_create: true - fail
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '.config.saml | {name_id_transformations, allow_create, allow_update, allow_link}'| Symptom | Cause | Fix |
|---|---|---|
| everyone fails on a new org | allow_create: false with no directory | turn it on, or provision via SCIM first |
| everyone fails after an email change upstream | step 1 matched nothing and step 2 matched a different user | pin external_id to a stable attribute |
NameID is an opaque id | name_id_transformations: "email" needs the IdP to release an email attribute | ask them to release email, or set "saml_subject_hash" and allow_link: true |
| it worked, then stopped | a certificate rotation dropped the connection to draft | re-verify and re-activate |
For a customer with SCIM, allow_create: false is correct. It turns "user not found" from a support ticket into a visible data-quality problem.
#Attribute mapping
The assertion verifies and the user is found, but the profile is wrong.
| Problem | Symptom | Fix |
|---|---|---|
Entra sends preferred_username, not email | access_denied or the wrong user | attribute_mapping.email = "preferred_username" |
groups are object ids | the groups attribute is full of GUIDs | map through your own lookup table, or group_name_template: "{name}" and slug them |
active is the string "false" | deactivated users can still log in | active_value: "false". ulex compares as a string, so this works |
no groups attribute at all | groups is absent from the payload | the IdP app is not configured to release it. group_attribute: "groups" does not make the IdP send it |
department is a localised display name | your role mapping silently matches nothing | resolve it yourself against a table you control |
external_id changes on re-import | duplicate users on every sync | pin it to a custom attribute, not id |
curl -sS "$BASE/connections/$CON_ID" -H "$AUTH" | jq '.config.saml.attribute_mapping'To see what the IdP actually sends, drive one login and read the attributes:
{ "name": "ulex_simulate_login", "arguments": {
"application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
"email": "dana@globex.example",
"connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
"protocol": "saml"
} }{
"outcome": "success",
"name_id": "okta-00u1sAM2xY8ZQ4H1",
"attributes": { "email": "dana@globex.example", "firstName": "Dana", "groups": ["engineering"], "userId": "00u1sAM2xY8ZQ4H1" }
}#Reproducing a customer's IdP headlessly
You do not need their Okta to develop against.
pnpm mock:up # the fixture IdP on localhost:4001{
"name": "ulex_create_connection",
"arguments": {
"name": "Local fixture IdP",
"config": {
"strategy": "saml",
"saml": {
"entity_id": "http://localhost:4001/saml/metadata",
"sso_url": "http://localhost:4001/saml/sso",
"x509_certificate": "MIIE1DCCA3CgAwIBAgIULSJ…",
"name_id_format": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
"allow_create": true,
"allow_link": true,
"attribute_mapping": { "email": "email", "first_name": "firstName", "last_name": "lastName", "groups": "groups" }
}
}
}
}Six fixture users, each with a different failure mode — success, MFA, MFA failure, unknown user, replay, and an artificial delay for timeout tests. SAML API: headless SP-initiated testing.
And to get a real signed assertion without a browser:
{ "name": "ulex_simulate_login", "arguments": {
"application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
"email": "dana@acme.example",
"protocol": "saml",
"return_assertion": true
} }Feed assertion_b64 straight into your app's ACS handler in a test. It is a real, signed, correctly-timed assertion with real attributes.
#Checklist before you escalate to the customer
[ ] ulex_verify_connection returns valid: true
[ ] connection.state is "active"
[ ] connection.config.saml.x509_certificate matches what the IdP signs with
[ ] connection.config.saml.audience_uri matches what the IdP puts in Audience
[ ] the IdP app's ACS URL matches ulex's
[ ] the IdP app has "signed assertions" enabled
[ ] the IdP's Name ID format matches config.saml.name_id_format
[ ] the IdP's clock is NTP-synchronised
[ ] the IdP releases every attribute in config.saml.attribute_mapping
[ ] ulex_verify_connection passes expires_within_30_daysIf all ten pass and the login still fails, it is ulex. Send us the request_id and the auth_attempt id, and quote Incident response for what we will do with them.