Skip to content

Add OIDC group and admin claim syncing#5

Open
Hudint wants to merge 1 commit into
moghtech:mainfrom
Hudint:feat/oidc-groups-admin-sync
Open

Add OIDC group and admin claim syncing#5
Hudint wants to merge 1 commit into
moghtech:mainfrom
Hudint:feat/oidc-groups-admin-sync

Conversation

@Hudint

@Hudint Hudint commented Jun 16, 2026

Copy link
Copy Markdown

What

Adds opt-in syncing of identity-provider state onto users on each OIDC login (both new registrations and existing users).

OidcConfig gains four optional fields, all defaulting to empty so behavior is unchanged unless configured:

  • groups_claim — claim holding the user's groups (array or single string)
  • admin_claim — claim signalling admin (bool, or truthy string / number)
  • admin_group — group whose members are treated as admin (matched against groups_claim)
  • additional_scopes — extra scopes to request, e.g. groups

How

  • UsernameAdditionalClaims captures arbitrary extra claims via #[serde(flatten)].
  • OidcProvider::get_groups_and_admin reads groups + admin from the id token, falling back to userinfo only for what is still missing.
  • Admin is granted when admin_claim is truthy OR the user is a member of admin_group (see resolve_admin).
  • Apps consume the result through a new AuthImpl::sync_oidc_user_claims hook, which defaults to a no-op, so existing implementations are unaffected.

Includes unit tests for claim parsing, admin resolution and config backwards-compatibility.

Motivation

Lets downstream apps map identity-provider groups onto their own groups and grant admin straight from the IdP, instead of managing it manually after each login.

Optionally mirror identity-provider state onto users on each OIDC
login (new and existing). OidcConfig gains groups_claim, admin_claim,
admin_group and additional_scopes, all defaulting to empty so nothing
changes unless configured.

Additional claims are captured via serde flatten; admin is granted
when admin_claim is truthy or the user is in admin_group. Apps consume
the result through the new AuthImpl::sync_oidc_user_claims hook, which
defaults to a no-op.
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.

1 participant