Repository navigation
feat(oidc): opt-in P_OIDC_SYNC_ROLES to make provider groups authoritative - #1867
Open
stalingino wants to merge 2 commits into
Open
stalingino wants to merge 2 commits into
stalingino wants to merge 2 commits into
Conversation
…ative For a returning OIDC user, roles from the groups claim are added to the roles the user already has and nothing is removed. That keeps roles assigned inside Parseable (parseablehq#1356), but it also means removing a user from a group in the identity provider never revokes the matching Parseable role. P_OIDC_SYNC_ROLES=true (--oidc-sync-roles) makes the provider the source of truth: at every login the user's roles become exactly the roles their groups name, falling back to the default role as before. The default is off, so existing behaviour is unchanged. The merge rule is extracted into merge_oidc_roles with unit tests for both modes.
Contributor
|
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
With P_OIDC_SYNC_ROLES, removing a user's last provider group left an empty role set, and the native-account fallback (a native user with the same email) then handed the removed role back. Under sync that fallback is now skipped; the default role still applies. resolve_roles now receives the defined roles, users and default role instead of reading StorageMetadata and DEFAULT_ROLE, so it reads no global state and is unit-tested directly, including the native-account case.
Author
|
I have read the CLA Document and I hereby sign the CLA |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1864.
Description
For a returning OIDC user, roles from the
groupsclaim are added to the roles they already have and nothing is removed. That preserves roles assigned inside Parseable (#1356), but it also means removing a user from a group in the identity provider never revokes the matching Parseable role.This adds an opt-in setting,
P_OIDC_SYNC_ROLES/--oidc-sync-roles(defaultfalse). When enabled, at every login the user's roles are set to exactly the roles their groups name, falling back to the default role as today. With the default, behaviour is unchanged.Under sync, the native-account fallback (a native user with the same email lends its roles) is skipped, so removing a user's last group can't hand the role back; the default role still applies.
The merge rule is a small
merge_oidc_rolesfunction, andresolve_rolesnow receives the defined roles, users and default role instead of readingStorageMetadata/DEFAULT_ROLE, so it reads no global state and is unit-tested directly.update_user_if_changedalready persists a shrunk role set.Note: an existing session keeps its roles until it expires; the sync applies at the next login.
Testing
merge_oidc_roles_tests, 8 passed): formerge_oidc_roles, a new user gets the group roles, existing roles are kept by default, and with sync a removed group's role is revoked. Throughresolve_roles: with sync, the last group removed does not restore roles from a same-email native account; without sync, that fallback still works; groups replace existing roles; the default role applies when no group matches.P_OIDC_SYNC_ROLES=true: first login → roles[authors](the user's group); an admin addsextra-by-handviaPATCH /user/{id}/role/add→[authors, extra-by-hand]; next login →[authors]; the session can query.cargo clippy --lib -- -D warningsandcargo fmt --checkare clean.This PR has:


Confidence Score: 5/5
The reviewed changes appear safe to merge; no blocking issues remain.Summary
Adds opt-in OIDC role sync while keeping the existing behavior by default. The follow-up fixes the previously reported native-account fallback and adds direct tests for role selection.
Reviews (7) · Last reviewed commit: "fix(oidc): keep the native-account fallb..." · Reviewed by Greptile