feat: link groups to OIDC groups and sync membership at SSO sign-in #20

Merged
marti merged 1 commit from feature/oidc-group-mapping into develop 2026-11-06 12:09:46 +01:00
Owner

What

Admins can link an mcphub group to an identity provider group (for example an authentik group). Each SSO sign-in then keeps the user's membership in linked groups in step with the IdP's groups claim.

How it behaves

  • A group's admin page has a new SSO group field: the IdP group name exactly as sent in OIDC_GROUPS_CLAIM (authentik's profile scope sends groups).
  • At each OIDC sign-in the user joins every linked group the claim names, and leaves every group they were synced into that the claim no longer names.
  • group_members.source (manual / oidc) separates synced members from hand-added ones. Sign-in never touches manual memberships, and editing a member list keeps each remaining member's source.
  • Changing or clearing a link drops that group's synced members right away; they come back at their next sign-in.
  • Sync only runs at SSO sign-in. Password sign-ins do not sync, and an IdP removal takes effect at the next SSO sign-in.
  • A sync that changes anything emits access.changed and adds groupsAdded / groupsRemoved to the auth.oidc.login audit entry.

Changes

  • Migration 0003_oidc_group_links: groups.oidc_group, group_members.source enum.
  • syncOidcGroups in apps/api/src/services/auth/oidc.ts, called from resolveOidcAccount.
  • Group.oidcGroup, member source, and oidcGroup on create/update bodies in packages/shared. The admin REST API, OpenAPI and admin MCP pick these up automatically.
  • SPA: the SSO group field, a "synced from SSO" marker on members, and the linked name in the groups list.
  • Docs: architecture.md, configuration.md.

Testing

  • New API tests in apps/api/test/admin-users.test.ts cover sync, manual members, source kept on edit, and relink.
  • Lint, typecheck and the full test suite pass locally.

🤖 Generated with Claude Code

## What Admins can link an mcphub group to an identity provider group (for example an authentik group). Each SSO sign-in then keeps the user's membership in linked groups in step with the IdP's groups claim. ## How it behaves - A group's admin page has a new **SSO group** field: the IdP group name exactly as sent in `OIDC_GROUPS_CLAIM` (authentik's `profile` scope sends `groups`). - At each OIDC sign-in the user joins every linked group the claim names, and leaves every group they were synced into that the claim no longer names. - `group_members.source` (`manual` / `oidc`) separates synced members from hand-added ones. Sign-in never touches manual memberships, and editing a member list keeps each remaining member's source. - Changing or clearing a link drops that group's synced members right away; they come back at their next sign-in. - Sync only runs at SSO sign-in. Password sign-ins do not sync, and an IdP removal takes effect at the next SSO sign-in. - A sync that changes anything emits `access.changed` and adds `groupsAdded` / `groupsRemoved` to the `auth.oidc.login` audit entry. ## Changes - Migration `0003_oidc_group_links`: `groups.oidc_group`, `group_members.source` enum. - `syncOidcGroups` in `apps/api/src/services/auth/oidc.ts`, called from `resolveOidcAccount`. - `Group.oidcGroup`, member `source`, and `oidcGroup` on create/update bodies in `packages/shared`. The admin REST API, OpenAPI and admin MCP pick these up automatically. - SPA: the SSO group field, a "synced from SSO" marker on members, and the linked name in the groups list. - Docs: `architecture.md`, `configuration.md`. ## Testing - New API tests in `apps/api/test/admin-users.test.ts` cover sync, manual members, source kept on edit, and relink. - Lint, typecheck and the full test suite pass locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat: link groups to OIDC groups and sync membership at SSO sign-in
All checks were successful
CI / check (pull_request) Successful in 5m44s
9879d62026
A group can name an IdP group (groups.oidc_group). Each OIDC sign-in
adds the user to every linked group in their groups claim and removes
the memberships it synced earlier that the claim no longer names.
group_members.source tells synced members from manual ones, so admin
edits are never undone by a sign-in. Changing a link drops the group's
synced members; they return at their next sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
marti merged commit e0d2692829 into develop 2026-11-06 12:09:46 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
marti/mcphub!20
No description provided.