Skip to content

Commit 535b1bc

Browse files
devGregAclaude
andcommitted
feat(authorization): reintroduce authorized_users M2M on Product / Product_Type
Forward-only schema migration adding authorized_users = M2M(Dojo_User) back to Product and Product_Type. This is the foundation field for the legacy permission model rewrite that replaces the RBAC role hierarchy with simple membership checks (is_superuser, is_staff, or in authorized_users). The field was originally on these models pre-DefectDojo#3757 (AuthZv2.0, late 2020) and was removed in 0138_remove_authorized_users.py once auth-v2 became the canonical authorization system. Reintroducing it now is the first step toward unwinding auth-v2 from the upstream codebase while preserving backward compatibility for installations that still want the RBAC tier (those will continue to be served by the dojo-pro plugin). This is a pure additive migration. The auth_role / dojo_global_role / dojo_product_member / dojo_product_group / dojo_product_type_member / dojo_product_type_group / dojo_dojo_group_member tables remain in the database; they will be released from dojo's app state by a follow-up SeparateDatabaseAndState migration so dojo-pro can adopt them. Subsequent commits will: - rewrite dojo/authorization/ contents to the legacy model - add a data migration backfilling authorized_users from RBAC tables - simplify ~117 callers and ~47 templates to the legacy action vocabulary Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent fb6b069 commit 535b1bc

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 5.2.13 on 2026-04-30 00:59
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('dojo', '0265_usercontactinfo_ui_use_tailwind'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='product',
15+
name='authorized_users',
16+
field=models.ManyToManyField(blank=True, related_name='authorized_products', to='dojo.dojo_user'),
17+
),
18+
migrations.AddField(
19+
model_name='product_type',
20+
name='authorized_users',
21+
field=models.ManyToManyField(blank=True, related_name='authorized_product_types', to='dojo.dojo_user'),
22+
),
23+
]

dojo/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ class Product_Type(BaseModel):
833833
key_product = models.BooleanField(default=False)
834834
members = models.ManyToManyField(Dojo_User, through="Product_Type_Member", related_name="prod_type_members", blank=True)
835835
authorization_groups = models.ManyToManyField(Dojo_Group, through="Product_Type_Group", related_name="product_type_groups", blank=True)
836+
authorized_users = models.ManyToManyField(Dojo_User, related_name="authorized_product_types", blank=True)
836837

837838
class Meta:
838839
ordering = ("name",)
@@ -1169,6 +1170,7 @@ class Product(BaseModel):
11691170
tid = models.IntegerField(default=0, editable=False)
11701171
members = models.ManyToManyField(Dojo_User, through="Product_Member", related_name="product_members", blank=True)
11711172
authorization_groups = models.ManyToManyField(Dojo_Group, through="Product_Group", related_name="product_groups", blank=True)
1173+
authorized_users = models.ManyToManyField(Dojo_User, related_name="authorized_products", blank=True)
11721174
prod_numeric_grade = models.IntegerField(null=True, blank=True)
11731175

11741176
# Metadata

0 commit comments

Comments
 (0)