Skip to content

Commit baf0f3e

Browse files
committed
devGregA elevate Writer Global_Role to is_staff in legacy auth backfill
Adds Writer to the is_staff flip set in 0267_backfill_authorized_users so Writer Global_Role users keep visibility post-conversion instead of silently dropping to nothing. Reader stays excluded since legacy has no read-only-everywhere primitive. Updates the matching tuple in preview_legacy_authorization_migration so the dry-run report tracks the migration, and documents the full RBAC -> legacy mapping in the 2.59 upgrade notes.
1 parent 686ce28 commit baf0f3e

3 files changed

Lines changed: 23 additions & 9 deletions

File tree

docs/content/releases/os_upgrading/2.59.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ In 2.59 the classic UI restores the **"Authorized Users"** panel on the Product
2020

2121
Both endpoints are gated so only `is_staff` / `is_superuser` users can add or remove. Non-staff users see the panel but no management actions.
2222

23+
### How RBAC rows are converted
24+
25+
The data migration `0267_backfill_authorized_users` translates RBAC tables into the legacy model with the following rules:
26+
27+
| RBAC row | Legacy effect |
28+
|---|---|
29+
| `Product_Member` (any role, direct or via `Product_Group` + `Dojo_Group_Member`) | Adds the user to `Product.authorized_users` |
30+
| `Product_Type_Member` (any role, direct or via `Product_Type_Group` + `Dojo_Group_Member`) | Adds the user to `Product_Type.authorized_users` |
31+
| `Global_Role(Owner)` (direct or via group) | Sets `User.is_superuser = True` |
32+
| `Global_Role(Writer | Maintainer | API_Importer)` (direct or via group) | Sets `User.is_staff = True` |
33+
| `Global_Role(Reader)` | No global elevation — relies on per-product membership |
34+
35+
Per-product role granularity (Reader vs Writer vs Maintainer vs Owner) collapses to membership-only because the legacy model has no per-product role concept. `Dojo_Group` structure as a permission-bearing entity is also lost; only the flattened individual user memberships remain.
36+
2337
### Required actions
2438

2539
- **Database migrations run automatically on upgrade.** Existing access is carried forward into the legacy `authorized_users` model. Existing data is preserved.

dojo/db_migrations/0267_backfill_authorized_users.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
-> Product_Type.authorized_users (flattened)
2222
Global_Role(Owner) for user -> User.is_superuser = True
2323
Global_Role(Owner) via group -> all group members.is_superuser = True
24-
Global_Role(Maintainer|API_Importer) for user
24+
Global_Role(Writer|Maintainer|API_Importer) for user
2525
-> User.is_staff = True
26-
Global_Role(Maintainer|API_Importer) via group
26+
Global_Role(Writer|Maintainer|API_Importer) via group
2727
-> all group members.is_staff = True
28-
Global_Role(Writer|Reader) -> no global elevation
28+
Global_Role(Reader) -> no global elevation
2929
(relies on per-product membership)
3030
3131
Things lost on this transition (acknowledged in the upgrade release notes):
@@ -96,13 +96,13 @@ def backfill_authorized_users(apps, schema_editor):
9696

9797
elevated_user_ids = list(
9898
Global_Role.objects.filter(
99-
role__name__in=("Maintainer", "API_Importer"),
99+
role__name__in=("Writer", "Maintainer", "API_Importer"),
100100
user__isnull=False,
101101
).values_list("user_id", flat=True),
102102
)
103103
elevated_group_ids = list(
104104
Global_Role.objects.filter(
105-
role__name__in=("Maintainer", "API_Importer"),
105+
role__name__in=("Writer", "Maintainer", "API_Importer"),
106106
group__isnull=False,
107107
).values_list("group_id", flat=True),
108108
)

dojo/management/commands/preview_legacy_authorization_migration.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
added (broken down by source: direct member rows vs flattened group
1717
members).
1818
* Users that would be flipped to ``is_superuser=True`` (Global_Role.Owner).
19-
* Users that would be flipped to ``is_staff=True`` (Global_Role.Maintainer
20-
/ API_Importer).
19+
* Users that would be flipped to ``is_staff=True`` (Global_Role.Writer /
20+
Maintainer / API_Importer).
2121
* Counts of role granularity that the legacy model cannot preserve
2222
(Reader vs Writer vs Maintainer per product, group membership as a
2323
permission-bearing entity, configuration permissions per codename).
@@ -109,13 +109,13 @@ def _build_report(self):
109109

110110
elevated_user_ids = set(
111111
Global_Role.objects.filter(
112-
role__name__in=("Maintainer", "API_Importer"),
112+
role__name__in=("Writer", "Maintainer", "API_Importer"),
113113
user__isnull=False,
114114
).values_list("user_id", flat=True),
115115
)
116116
elevated_group_ids = list(
117117
Global_Role.objects.filter(
118-
role__name__in=("Maintainer", "API_Importer"),
118+
role__name__in=("Writer", "Maintainer", "API_Importer"),
119119
group__isnull=False,
120120
).values_list("group_id", flat=True),
121121
)

0 commit comments

Comments
 (0)