You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8dec213
Browse filesBrowse the repository at this point in the historyBrowse files
feat(plugin-auth, platform-objects): an SSO provider maps who a sign-in resolves to (SAML email, first, last and display name; OIDC email and name), and a refused SAML response names its cause
7
+
8
+
Clause-②: yes (widening)
9
+
Metadata-protocol: none
10
+
11
+
**Attribute mapping.**`@better-auth/sso` reads a SAML user's email from the `email` attribute (else the NameID) and the name from `givenName` + `surname`, else `displayName`, else the NameID. Okta sends the full name as `name` and Entra ID sends claim URIs, so their users were named after their NameID, and nothing in the platform could map other attribute names.
12
+
13
+
-**Register SAML Provider** takes four new optional fields, `mapEmail`, `mapFirstName`, `mapLastName` and `mapName`, stored as the provider's `mapping.email` / `firstName` / `lastName` / `name` beside the groups attribute. Blank leaves the default. The help text names the Okta and Entra ID attribute names.
14
+
-**Show Attribute Mapping** and **Edit Attribute Mapping** on `sys_sso_provider` show and change the mapping of an existing provider, SAML or OIDC, through two new platform-admin bridges, `POST /api/v1/auth/admin/sso/get-attribute-mapping` and `POST /api/v1/auth/admin/sso/set-attribute-mapping` (route ledger rows, `server-only`, `requires: 'sso'`). A member left untouched keeps its value, a cleared one goes back to the default, and the groups claim and every other member of the stored mapping are kept. An OIDC provider maps `email` and `name` only; `firstName` / `lastName` on one answer `400 INVALID_REQUEST`. An unknown provider is `404 RESOURCE_NOT_FOUND`. The answer carries the provider id, its protocol and the four members, nothing else of the stored configuration. The edit is not offered to an AI caller: the email member decides which account a sign-in links to.
15
+
- The labels are translated in all ten locales.
16
+
17
+
**SAML refusal causes.** The vendor answers every samlify rejection with `error=saml_error&error_description=Invalid SAML response`. After it refuses, the posted response is now read once more against the provider's configured signing certificates and IdP entity id, in samlify's order, and `error_description` names the first of four causes that applies: `saml_idp_status_not_success`, `saml_response_unsigned`, `saml_signing_certificate_mismatch` (the IdP certificate rotation case) or `saml_issuer_mismatch`. One `warn` line carries the provider id, `protocol: 'saml'` and the cause. `error=saml_error` is unchanged, any other refusal keeps `Invalid SAML response`, and nothing about the accept decision changes. No cryptography runs; neither the redirect nor the line carries assertion content, and the answer is the same for every account. `fast-xml-parser` (the parser the vendor already uses) becomes a direct dependency of plugin-auth.
18
+
19
+
Documented in `content/docs/permissions/sso.mdx` ("Map the user's email and name", "Why a SAML sign-in was refused").
Copy file name to clipboardExpand all lines: content/docs/permissions/sso.mdx
+58-1Lines changed: 58 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -307,7 +307,7 @@ any token content, and the answer does not depend on whether the account exists.
307
307
|`token_not_verified`| Any other refusal of the ID token. The server log carries the detail. |
308
308
309
309
The list is exported as `SSO_OIDC_REFUSAL_CAUSES` from `@objectstack/plugin-auth`.
310
-
SAML refusals do not name their cause yet.
310
+
SAML refusals name theirs too: see [Why a SAML sign-in was refused](#why-a-saml-sign-in-was-refused).
311
311
312
312
---
313
313
@@ -330,6 +330,11 @@ Fill in the IdP details collected by the **Register SAML Provider** action:
330
330
|`entryPoint`| ✅ | The IdP's SAML single sign-on (redirect) URL that receives the `SAMLRequest`. |
331
331
|`cert`| ✅ | The IdP's X.509 signing certificate (PEM body) — used to verify assertion signatures. |
332
332
|`identifierFormat`| — | Requested SAML NameID format (defaults to the IdP's configured format), e.g. `urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress`. |
333
+
|`mapEmail`| — | Assertion attribute the user's email is read from. Defaults to `email`, then the NameID. |
334
+
|`mapFirstName`| — | Assertion attribute the user's first name is read from. Defaults to `givenName`. |
335
+
|`mapLastName`| — | Assertion attribute the user's last name is read from. Defaults to `surname`. |
336
+
|`mapName`| — | Assertion attribute the user's full name is read from when the first and last name are absent. Defaults to `displayName`, then the NameID. |
337
+
|`mapGroups`| — | Assertion attribute that carries the user's groups (see [Grant permission sets from IdP groups](#grant-permission-sets-from-idp-groups)). |
333
338
334
339
On success the response returns the two **Service Provider (SP)** URLs you
335
340
configure on the IdP side:
@@ -366,6 +371,58 @@ configure on the IdP side:
366
371
> Signature, timestamp, and replay validation are handled by `@better-auth/sso`
367
372
> (samlify). You only supply the IdP's signing certificate at registration time.
368
373
374
+
### Map the user's email and name
375
+
376
+
A SAML sign-in reads the user's email and name from assertion attributes. With
377
+
nothing mapped, the email is the `email` attribute (else the NameID) and the name
378
+
is `givenName` + `surname`, else `displayName`, else the NameID. Okta and Entra ID
379
+
use other attribute names, so their users are named after their NameID until the
lastName?, name? }`). The email member decides which account a sign-in is linked
405
+
to, so change it with care on a provider that already has users.
406
+
407
+
### Why a SAML sign-in was refused
408
+
409
+
When the identity provider's SAML response is not accepted, the sign-in lands on
410
+
your `errorCallbackURL` (or the platform's sign-in page) with `error=saml_error`.
411
+
For the four common configuration mistakes, `error_description` names the cause
412
+
instead of `InvalidSAMLresponse`, and the server writes one `warn` log line
413
+
with the `providerId`, `protocol:'saml'` and the same `cause`. The cause is read
414
+
from the response the IdP posted, compared with the provider's configured signing
415
+
certificate and IdP entity ID; neither the redirect nor the log line carries any
416
+
assertion content, and the answer does not depend on whether the account exists.
417
+
418
+
| `error_description` | What to check |
419
+
| :--- | :--- |
420
+
| `saml_idp_status_not_success` | The IdP answered with a failure status instead of an assertion: for example Entra ID's "user is not assigned to the application". Check the user's assignment and the IdP's sign-in log. |
421
+
| `saml_response_unsigned` | Neither the response nor its assertion is signed. Turn on response or assertion signing in the IdP application. |
422
+
| `saml_signing_certificate_mismatch` | The response is signed with a certificate the provider does not have, usually after the IdP rotated its signing certificate. Update the provider's certificate (several can be configured while both are in use). |
423
+
| `saml_issuer_mismatch` | The response is signed with the configured certificate but comes from another IdP entity ID. Check the provider's IdP Entity ID against the IdP's issuer. |
424
+
| `InvalidSAMLresponse` | Any other refusal of the response (for example an expired assertion or a broken signature). The server log carries the vendor's line. |
0 commit comments