Repository navigation
Reader role migration: give administrators the reader role too, so one an identity provider demotes stays a reader - #810
Merged
Conversation
Migration 0013 gave the built-in `reader` role only to users holding neither `admin` nor `writer`. An identity provider or upstream that manages an account's admin rights (OIDC `admin_groups`/`admin_claim`, a credential-forwarding `admin_group`) demotes it with `sync_admin_role`, which takes `admin` away and nothing else. An account provisioned on 2.2 holds the realm's `new_account_access` role next to `admin` and stays a reader; an administrator from before the upgrade held `admin` alone and was left Roles only, reading nothing. 0013 now gives `reader` to every user that is not a writer, administrators included. While they are administrators it adds nothing (the access level shown is the highest built-in role). 0013 has not shipped, so it changes in place. The migration test checks that an administrator holds both roles after the upgrade and a reader remains once the identity provider takes `admin` away; 733.upgrade.md says so. Fixes #792 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJc1H3748D8sheqhKTV
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 #792
Problem
Migration 0013 gave the built-in
readerrole only to users holding neitheradminnorwriter. An identity provider or upstream demotes an account throughsync_admin_role(…, false)(crates/db/src/authz_dao.rs:380-408), which deletesadminand nothing else. That covers OIDCadmin_groups/admin_claimand a credential-forwardingadmin_group.new_account_accessrole next toadmin, so a demotion leaves it a reader.adminalone, so the same demotion left it Roles only. It got 403 on every private repository while everyone else read them.Change
migrations/0013_reader_role.sqlgivesreaderto everykind = 'user'account that does not holdwriter, administrators included.accessLevel), and changing the level there removes every other level role.writeralready.docs/changes/2.2.0/733.upgrade.mdsays administrators get the role too.Tests
readers_before_the_upgrade_get_the_reader_role(crates/db/tests/migrations.rs) checks:adminandreaderafter the upgrade;sync_admin_role(…, false), as an identity provider's demotion runs it,readerremains.Without the migration change it fails with
left: ["admin"], right: ["admin", "reader"].Run locally:
cargo test -p forge-db --test migrations: 5 passed;cargo clippy -p forge-db --all-targets -- -D warnings,cargo fmt --all --checkandcargo xtask changelog --check: clean.Generated by Claude Code