Repository navigation
Reader role migration: rename the role in workload-identity rules too, so they keep their grants - #784
Merged
Conversation
Migration 0013 renames an administrator's role named `reader` to `reader-<id>` before it seeds the built-in `reader`. The rules of a workload-identity realm name their role, resolved by name on every CI token, so a rule that named the custom role would grant the built-in one, read on every repository, after the upgrade. The migration now rewrites those rules to the renamed role first; the realm's policy digest changes with it, so its exchanged keys end and its jobs exchange again. Fixes #749 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJb6V3DHD5wQrsYhKda
schmitch
enabled auto-merge
November 2, 2026 19:31
A workload-identity rule that names `reader` while no role of that name exists (a deleted one) refused the jobs it matched; after the upgrade it resolves to the built-in `reader`. There is no role the migration could point it at, so the upgrade note and the migration's comment say so and ask administrators to check their rules before upgrading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012e6DJb6V3DHD5wQrsYhKda
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 #749
What
Migration 0013 (#733, #734) renames a role an administrator had named
readertoreader-<id>, then seeds the built-inreader, which reads every repository. The rules of a workload-identity realm name their role (rules[].role), resolved by name on every CI token (crates/server/src/auth/wif.rs). The migration left them alone, so after the upgrade a rule that pointed at the administrator's role would grant the built-in one: every CI job it matches would read every repository.How
Before the rename, 0013 rewrites each
workload_identityrealm whoseconfig.rulesnamesreader(trimmed, as the realm's validation trims it):reader-<id>;updated_atis bumped;reader, are untouched.The realm's policy digest changes with its rules, so keys its jobs exchanged before the upgrade stop working (
realm_current_now,wif.rs:846) and the jobs exchange their ID tokens again. Those keys held the renamed role's id, so this only costs an exchange.0013 is not released yet, so it is changed in place. A database migrated from
mainsince #734 will report 0013 as modified, as for any unreleased migration.Documented: a rule whose
readerrole does not existA rule can name
readerwhile no role of that name exists, for example after the role was deleted, which no check stops. In 2.1 such a rule refused the jobs it matched, fail-closed. From the upgrade on, it grants the built-inreader. There is no role the migration could point it at, so it stays as it is. Instead:docs/changes/2.2.0/749.upgrade.mdsays so and asks administrators to check each workload-identity realm's rules under Admin → Authentication before upgrading, and to point such a rule at a role that exists or remove it;Tests
crates/db/tests/migrations.rsreaders_before_the_upgrade_get_the_reader_rolenow adds two realms:readertwice (once with spaces) around aci-pubrule: afterwards it namesreader-<id>for both, keeps theci-pubrule and the conditions as they were, and records the change;reader: it is unchanged.--test migrations). With the original 0013 it fails:cargo clippy -p forge-db --all-targets -- -D warnings,cargo fmt --checkandcargo xtask changelog --checkare clean.🤖 Generated with Claude Code
https://claude.ai/code/session_012e6DJb6V3DHD5wQrsYhKda