Skip to content

Commit 8dec213

Browse files
committed
wip: docs and changeset
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzhMu5u3iHHSSD7mx8c
1 parent 0972a63 commit 8dec213

2 files changed

Lines changed: 77 additions & 1 deletion

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/platform-objects': patch
4+
---
5+
6+
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").

‎content/docs/permissions/sso.mdx‎

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ any token content, and the answer does not depend on whether the account exists.
307307
| `token_not_verified` | Any other refusal of the ID token. The server log carries the detail. |
308308

309309
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).
311311

312312
---
313313

@@ -330,6 +330,11 @@ Fill in the IdP details collected by the **Register SAML Provider** action:
330330
| `entryPoint` | ✅ | The IdP's SAML single sign-on (redirect) URL that receives the `SAMLRequest`. |
331331
| `cert` | ✅ | The IdP's X.509 signing certificate (PEM body) — used to verify assertion signatures. |
332332
| `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)). |
333338

334339
On success the response returns the two **Service Provider (SP)** URLs you
335340
configure on the IdP side:
@@ -366,6 +371,58 @@ configure on the IdP side:
366371
> Signature, timestamp, and replay validation are handled by `@better-auth/sso`
367372
> (samlify). You only supply the IdP's signing certificate at registration time.
368373
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
380+
provider maps them:
381+
382+
| Member | Default | Okta (common) | Entra ID |
383+
| :--- | :--- | :--- | :--- |
384+
| Email | `email` | `email` | `http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress` |
385+
| First name | `givenName` | — | `http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname` |
386+
| Last name | `surname` | — | `http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname` |
387+
| Display name | `displayName` | `name` | `http://schemas.microsoft.com/identity/claims/displayname` |
388+
389+
Okta sends the attributes its application's attribute statements name, so check
390+
those statements for the exact names. Map them on the **Register SAML Provider**
391+
form, or on an existing provider:
392+
393+
- **Show Attribute Mapping** shows the attributes (SAML) or claims (OIDC) the
394+
provider reads now; an empty member uses the default.
395+
- **Edit Attribute Mapping** changes the members you fill in. A member you leave
396+
untouched keeps its value, and a member you clear goes back to the default.
397+
The groups claim and every other member of the mapping are kept as stored.
398+
An OIDC provider maps `email` and `name` only (its default claims are `email`
399+
and `name`).
400+
401+
Both run on platform-admin standing, through `POST
402+
/api/v1/auth/admin/sso/get-attribute-mapping` and `POST
403+
/api/v1/auth/admin/sso/set-attribute-mapping` (`{ providerId, email?, firstName?,
404+
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 `Invalid SAML response`, 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+
| `Invalid SAML response` | Any other refusal of the response (for example an expired assertion or a broken signature). The server log carries the vendor's line. |
425+
369426
---
370427
371428
## Per-provider sign-in options

0 commit comments

Comments
 (0)