Repository navigation
feat(sso): enforce an IdP group/role claim allow-list per provider - #729
Conversation
Providers could only be restricted by email domain, so installations that must limit access to one Entra ID / Okta / Keycloak group had to put a separate authentication proxy in front of Paca. Each OIDC provider now has an optional group policy: a group claim name (a plain claim, a URL-style claim, or a dotted path such as realm_access.roles) and a list of allowed values. When enabled, the claim of the verified ID token is checked in CompleteLogin before any account is looked up, linked or provisioned, so it applies to returning users as well as first-time ones, and a denied sign-in creates no account or identity. The check fails closed: a missing, null, empty, non-string or otherwise malformed claim is denied, as is an Entra groups-overage token (the _claim_names / _claim_sources pointer is not resolved). The reason is logged; the user only sees a generic group_not_allowed error. The policy is off by default, so existing providers behave exactly as before. - migration 000085 adds group_policy_enabled, group_claim, allowed_groups - admin API/DTO, repository and the provider dialog expose the new fields with validation (claim and at least one group required when enabled) - group_not_allowed login error and admin strings in all locales - unit tests for claim evaluation and CompleteLogin, plus an API e2e case - docs: restricting sign-in by group, Entra ID setup incl. the overage caveat, and other providers Signed-off-by: Asish Kumar <[email protected]>
There was a problem hiding this comment.
ℹ️ No critical issues — one minor documentation suggestion inline.
Reviewed changes
- Claim evaluation — new
checkGroupPolicy/groupDenialReason/lookupClaim/validClaimPathingroups.goread the configured claim from the verified ID token and fail closed on absent,null, empty, malformed, mixed-type, or Entra overage claims, with exact case-sensitive matching. - Enforcement point —
CompleteLoginruns the check after ID-token and nonce verification and beforeResolveUser, so a denied sign-in creates no account and no identity link and applies to returning users. - Provider configuration — migration
000085plus domain, repository, DTO and handler wiring forgroup_policy_enabled,group_claimandallowed_groups; validation requires a usable claim path and at least one allowed value only when the policy is enabled. - Admin UI — provider dialog toggle and claim/group inputs, a
splitGroupshelper that preserves spaces in group names, andgroup_not_allowedhandling on the login page, with all nine locales updated for both namespaces. - Docs and tests — new SSO guide section covering generic OIDC and Entra setup (including the overage caveat), plus unit coverage for every claim shape and an API e2e case for allowed, denied, returning-user and disabled-policy sign-ins.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
|
|
||
| ### Microsoft Entra ID | ||
|
|
||
| 1. In the app registration, open **Token configuration → Add groups claim** and choose the group types you need. To keep tokens small, pick **Groups assigned to the application** and assign only the intended groups to the enterprise application. (Alternatively, define **App roles** and use the `roles` claim.) |
There was a problem hiding this comment.
Worth a caveat here: unlike group object IDs, Entra app roles are assigned per tenant in each tenant's Enterprise applications pane, so with a common/organizations issuer any tenant admin can grant the allowed roles value to their own users. That makes a roles allow-list grantable by the wrong tenant when auto-provisioning is on; suggest saying to use group object IDs or a single-tenant issuer for multi-tenant app registrations.
pikann
left a comment
There was a problem hiding this comment.
LGTM! Thank you for the contribution! 🚀

Summary
Adds a per-provider IdP group/role allow-list for SSO (closes #675). An admin can configure, per OIDC provider, a trusted group claim and the values allowed to sign in. The claim is read from the verified ID token in
CompleteLogin, before any account is looked up, linked or provisioned, so it applies to returning and first-time users alike. A denied sign-in creates no account and no identity link.null, empty, not a string/list of strings, or holds none of the allowed values._claim_names/_claim_sources) is denied by default. It is not resolved, and the docs explain how to avoid it.realm_access.roles.group_not_allowederror. The reason is logged without the claim contents.Changes:
000085addsgroup_policy_enabled,group_claimandallowed_groupstooidc_providers.group_not_allowedlogin error and admin strings are added to all locales.docs/guides/sso-oidc.mdcovers restricting sign-in by group, Entra ID setup including the overage caveat, and other providers.Type of Change
Checklist
Testing
go test ./internal/service/sso/covers claim evaluation (string, array, nested, URL-style, absent, null, empty, wrong type, non-string element, overage) andCompleteLoginagainst a fake IdP (allowed, denied with no user or identity created, returning user who lost the group, policy disabled), plus config validation.TestSSOSignInhas a newgroup_policy_restricts_sign_incase, run withPACA_E2E=1against real Postgres and Redis.TestRealMigrations_ApplyCleanlyFromScratchalso passes.tsc,biome checkand the vitest i18n and SSO dialog tests pass.