From 087e79e6ed7681a609ed97be0b6f0dd11e8ca845 Mon Sep 17 00:00:00 2001 From: hugocasa Date: Thu, 5 Nov 2026 23:39:00 +0100 Subject: [PATCH] feat: configurable SSO email and username claims (#12235) * feat: configurable SSO email and username claims Two instance settings next to sso_groups_claim, read by OIDC and SAML logins: sso_email_claim and sso_username_claim (NameID means the SAML subject). A configured claim absent from a login falls back to the protocol default, so unset settings keep today's behaviour. Co-Authored-By: Claude Opus 5.5 * chore: bump ee-repo-ref Co-Authored-By: Claude Opus 5.5 * docs: say what a custom SSO email claim must be trusted for Co-Authored-By: Claude Opus 5.5 * chore: update ee-repo-ref to cb6aa42ad515529506531051a3cbfa0e0867c605 This commit updates the EE repository reference after PR #956 was merged in windmill-ee-private. Previous ee-repo-ref: 9f10709a6898df0682ae478955e18b9f201f4776 New ee-repo-ref: cb6aa42ad515529506531051a3cbfa0e0867c605 Automated by sync-ee-ref workflow. --------- Co-authored-by: Claude Opus 5.5 Co-authored-by: windmill-internal-app[bot] Co-authored-by: Ruben Fiszel --- backend/ee-repo-ref.txt | 2 +- .../windmill-common/src/global_settings.rs | 6 +++++ docs/auth-surface.md | 10 ++++++++ .../src/lib/components/instanceSettings.ts | 24 +++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/backend/ee-repo-ref.txt b/backend/ee-repo-ref.txt index 543c9e5e49..3e1264822e 100644 --- a/backend/ee-repo-ref.txt +++ b/backend/ee-repo-ref.txt @@ -1 +1 @@ -6e7173e9c35569b03251ed31c8798037204fe483 +cb6aa42ad515529506531051a3cbfa0e0867c605 diff --git a/backend/windmill-common/src/global_settings.rs b/backend/windmill-common/src/global_settings.rs index 82a807c31b..8984799227 100644 --- a/backend/windmill-common/src/global_settings.rs +++ b/backend/windmill-common/src/global_settings.rs @@ -159,6 +159,12 @@ pub const AUTO_LOGIN_PROVIDER_SETTING: &str = "auto_login_provider"; /// Name of the SAML attribute or OIDC userinfo claim carrying the user's IdP groups. Unset or /// empty leaves instance-group membership entirely to SCIM. pub const SSO_GROUPS_CLAIM_SETTING: &str = "sso_groups_claim"; +/// OIDC userinfo claim or SAML attribute holding the user's email. Unset, or absent from a +/// login, keeps the protocol's default (OIDC `email`, SAML NameID). +pub const SSO_EMAIL_CLAIM_SETTING: &str = "sso_email_claim"; +/// OIDC userinfo claim or SAML attribute (`NameID` for the subject's NameID) holding the +/// username given to an account created at login. Unset, or absent, keeps the default. +pub const SSO_USERNAME_CLAIM_SETTING: &str = "sso_username_claim"; pub const HUB_BASE_URL_SETTING: &str = "hub_base_url"; pub const HUB_ACCESSIBLE_URL_SETTING: &str = "hub_accessible_url"; pub const DISABLE_HUB_SETTING: &str = "disable_hub"; diff --git a/docs/auth-surface.md b/docs/auth-surface.md index 1d22ba7610..5932b8979a 100644 --- a/docs/auth-surface.md +++ b/docs/auth-surface.md @@ -160,6 +160,16 @@ Symbols, not line numbers, are cited: they drift less. "true"/"false" strings) and is only consulted for the claim above; only GitHub is filtered to `primary && verified`; a missing email is fabricated from `name` as `@windmill.dev` and reaches `login_externally` with `email_asserted = false`. +- **SSO claim names** (`sso_email_claim`, `sso_username_claim`, instance-wide, OIDC and SAML + alike): a configured claim absent from a login falls back to the protocol default (OIDC + `email` and the chain above, SAML NameID; `preferred_username` / the SAML username list), + so one setting serves providers that name it differently. A configured email claim counts + as asserted and can claim a `pending_oauth` account, so it must name an attribute users + cannot edit at the IdP; `email_verified` is only read when the claim is `email` (the MCP + external IdP instead refuses any token marked unverified, whatever its email claim: it never + creates or claims an account, so the stricter rule costs nothing there). GitHub and Nextcloud + keep their own email source. Accounts stay keyed by email: the username claim only names an + account at creation, and an email change at the IdP signs in as a different account. - **MCP access tokens from an external issuer** (`mcp_external_idp`, EE, `mcp/external_idp.rs`): taken only for a JWT whose unverified `iss` is the configured issuer, then verified against its discovery JWKS. With no audience configured, only a token typed as an access token (`at+jwt` diff --git a/frontend/src/lib/components/instanceSettings.ts b/frontend/src/lib/components/instanceSettings.ts index c14fb676cc..3f0462f8a6 100644 --- a/frontend/src/lib/components/instanceSettings.ts +++ b/frontend/src/lib/components/instanceSettings.ts @@ -862,6 +862,30 @@ export const settings: Record = { ee_only: '', actionButton: manageInstanceGroupsButton }, + { + label: 'SSO email claim', + description: + "The claim or SAML attribute holding a user's email. Windmill accounts are keyed by email.", + tooltip: + 'Leave empty to use the email claim on OIDC and the NameID on SAML. A login whose claim is missing falls back to that default, so one setting can serve providers that name it differently. The claim decides which account a login opens, so map it only to an attribute users cannot edit at the identity provider. GitHub and Nextcloud logins always use their own email source. A changed email signs in as a different user.', + key: 'sso_email_claim', + fieldType: 'text', + placeholder: 'email', + storage: 'setting', + ee_only: '' + }, + { + label: 'SSO username claim', + description: + 'The claim or SAML attribute holding the username given to an account created at its first SSO login. NameID means the SAML NameID.', + tooltip: + 'Leave empty to use preferred_username on OIDC and the usual username attributes on SAML (uid, username, preferred_username, UPN). A login whose claim is missing falls back to that default. Existing accounts keep their username. Has no effect when automatic username creation is off.', + key: 'sso_username_claim', + fieldType: 'text', + placeholder: 'preferred_username', + storage: 'setting', + ee_only: '' + }, { label: 'MCP external identity provider', description: