Skip to content

feat(sso): enforce an IdP group/role claim allow-list per provider - #729

Merged
pikann merged 1 commit into
Paca-AI:masterfrom
officialasishkumar:feature/sso-group-claim-allow-list
Nov 12, 2026
Merged

pikann merged 1 commit into
Paca-AI:masterfrom
officialasishkumar:feature/sso-group-claim-allow-list

Conversation

@officialasishkumar

Copy link
Copy Markdown
Contributor

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.

  • The policy is off by default; existing providers behave exactly as before. When it is off, the claim settings are ignored.
  • Fails closed when the claim is missing, null, empty, not a string/list of strings, or holds none of the allowed values.
  • Entra "groups overage" (_claim_names / _claim_sources) is denied by default. It is not resolved, and the docs explain how to avoid it.
  • Supports string and array claims, URL-style claim names, and nested paths such as realm_access.roles.
  • The user only sees a generic group_not_allowed error. The reason is logged without the claim contents.
  • Userinfo claims are not consulted; resolving overage through Microsoft Graph and group-to-role mapping are left out of scope, as in the issue.

Changes:

  • Migration 000085 adds group_policy_enabled, group_claim and allowed_groups to oidc_providers.
  • The domain, repository, DTO and handler carry the new fields. Validation requires a well-formed claim and at least one group when the policy is enabled.
  • The admin provider dialog has the new fields. The group_not_allowed login error and admin strings are added to all locales.
  • docs/guides/sso-oidc.md covers restricting sign-in by group, Entra ID setup including the overage caveat, and other providers.

Type of Change

  • Other (feature: SSO group allow-list)

Checklist

  • The change is focused and scoped.
  • Related documentation is updated.
  • New structure or direction is explained clearly.
  • I avoided unnecessary detail or premature abstraction.

Testing

  • go test ./internal/service/sso/ covers claim evaluation (string, array, nested, URL-style, absent, null, empty, wrong type, non-string element, overage) and CompleteLogin against a fake IdP (allowed, denied with no user or identity created, returning user who lost the group, policy disabled), plus config validation.
  • The API e2e TestSSOSignIn has a new group_policy_restricts_sign_in case, run with PACA_E2E=1 against real Postgres and Redis. TestRealMigrations_ApplyCleanlyFromScratch also passes.
  • Web: tsc, biome check and the vitest i18n and SSO dialog tests pass.

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]>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor documentation suggestion inline.

Reviewed changes

  • Claim evaluation — new checkGroupPolicy / groupDenialReason / lookupClaim / validClaimPath in groups.go read 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 — CompleteLogin runs the check after ID-token and nonce verification and before ResolveUser, so a denied sign-in creates no account and no identity link and applies to returning users.
  • Provider configuration — migration 000085 plus domain, repository, DTO and handler wiring for group_policy_enabled, group_claim and allowed_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 splitGroups helper that preserves spaces in group names, and group_not_allowed handling 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.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

Comment thread docs/guides/sso-oidc.md

### 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.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pikann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for the contribution! 🚀

@pikann
pikann merged commit c889d7f into Paca-AI:master Nov 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] SSO: enforce IdP group/role claim allow-list per provider

2 participants