mirror of
https://github.com/coder/coder.git
synced 2026-11-03 22:25:31 +08:00
refactor(coderd): restore agents-access cleanup migration (#28587)
## Summary - restore the `agents-access` data cleanup migration as `000587` (renumbered from `000585`; main advanced past that number) - revert the temporary RBAC tolerance for retired role names now that the migration strips stale grants - make the migration test discover its predecessor dynamically, since this branch does not carry main's `000585`/`000586` ## Stack context Stacked on #28186, which retires the `agents-access` role but intentionally ships without a migration so it can be backported across diverged migration numbers. This layer completes the retirement on main: it cleans up stale role grants in `users.rbac_roles`, `organization_members.roles`, and `organizations.default_org_member_roles`, then reverts the interim leniency (role expansion dropping legacy names, assignment validation ignoring them) that existed only to keep the migration-less base safe. `rbac.ReservedRoleName` still reserves the retired name so custom roles cannot shadow it on rollback. Do not backport this PR alongside the base PR. ## Rollback note The down migration restores effective access broadly because it cannot reconstruct which users previously held the removed role. ## Validation - `go build ./coderd/... ./enterprise/...` - full `coderd/database/migrations`, `coderd/rbac/...`, and `coderd/database/dbauthz` suites - targeted members tests in `coderd` - repository pre-commit checks (`lint/go`, `lint/ts`, etc.) > Mux created this pull request on Mike's behalf.
This commit is contained in:
@@ -847,12 +847,6 @@ func SlimRolesFromNames(names []string) []codersdk.SlimRole {
|
||||
convertedRoles := make([]codersdk.SlimRole, 0, len(names))
|
||||
|
||||
for _, name := range names {
|
||||
// Stored role arrays may retain retired built-in role names until
|
||||
// a cleanup migration lands. Hide them so consumers do not display
|
||||
// or resubmit them.
|
||||
if rbac.IsRetiredRoleName(name) {
|
||||
continue
|
||||
}
|
||||
convertedRoles = append(convertedRoles, SlimRoleFromName(name))
|
||||
}
|
||||
|
||||
@@ -925,14 +919,11 @@ func Organization(organization database.Organization) codersdk.Organization {
|
||||
DisplayName: organization.DisplayName,
|
||||
Icon: organization.Icon,
|
||||
},
|
||||
Description: organization.Description,
|
||||
CreatedAt: organization.CreatedAt,
|
||||
UpdatedAt: organization.UpdatedAt,
|
||||
IsDefault: organization.IsDefault,
|
||||
// Stored default role lists may retain retired built-in role names
|
||||
// until a cleanup migration lands. Hide them so settings forms do
|
||||
// not display or resubmit them.
|
||||
DefaultOrgMemberRoles: slices.DeleteFunc(slices.Clone(organization.DefaultOrgMemberRoles), rbac.IsRetiredRoleName),
|
||||
Description: organization.Description,
|
||||
CreatedAt: organization.CreatedAt,
|
||||
UpdatedAt: organization.UpdatedAt,
|
||||
IsDefault: organization.IsDefault,
|
||||
DefaultOrgMemberRoles: organization.DefaultOrgMemberRoles,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user