Commit ac1b1bb
committed
refactor: consolidate RBAC into dojo/authorization package
Move every RBAC / authorization concern into a single dojo/authorization/
package. Before this change authorization code lived in seven different
places: dojo/models.py (RBAC models), 14 per-app queries.py files
(get_authorized_*), every view file (@user_is_authorized decorators),
dojo/api_v2/permissions.py, dojo/location/api/permissions.py, and
dojo/templatetags/authorization_tags.py.
Changes
- Move 7 RBAC models (Role, Global_Role, Dojo_Group_Member,
Product_Member, Product_Group, Product_Type_Member,
Product_Type_Group) from dojo/models.py to
dojo/authorization/models.py. app_label='dojo' is preserved so no
migrations are needed; ~47 import sites are updated.
- Merge dojo/api_v2/permissions.py and
dojo/location/api/permissions.py into
dojo/authorization/api_permissions.py.
- Extract template-tag logic from
dojo/templatetags/authorization_tags.py into
dojo/authorization/template_filters.py; the templatetags module
becomes a thin registration proxy.
- Add dojo/authorization/query_filters.py (registry) and
dojo/authorization/query_registrations.py (~1.9k lines of RBAC
filter logic extracted from 14 per-app queries.py files). Each
get_authorized_* becomes a thin wrapper that defers to the registry
and falls back to unfiltered querysets when no RBAC backend is
registered.
- Add dojo/authorization/url_permissions.py mapping ~198 URL names to
permission checks plus dojo/authorization/middleware.py with
AuthorizationMiddleware enforcing them via process_view. Removes
@user_is_authorized, @user_has_global_permission, and
@user_is_configuration_authorized from 26 view files.
- Update dojo/authorization/__init__.py exports and trigger
query-filter registration at app startup.
Behavior is unchanged: authorization checks for the ~198 mapped URLs
now run in middleware (process_view) instead of view bodies, but
produce the same allow/deny outcome. Non-RBAC deployments keep working
because get_authorized_* falls back to unfiltered querysets.
Tests: unittests/test_permissions_audit.py exercises the URL-permission
map for completeness; existing API/UI suites pass.1 parent 5178368 commit ac1b1bb
85 files changed
Lines changed: 3015 additions & 2113 deletions
File tree
- dojo
- announcement
- api_v2
- asset/api
- authorization
- banner
- benchmark
- cred
- development_environment
- endpoint
- engagement
- finding_group
- finding
- github_issue_link
- group
- importers
- jira
- api
- location
- api
- management/commands
- note_type
- object
- organization/api
- product_type
- product
- regulations
- reports
- risk_acceptance
- settings
- sla_config
- survey
- templatetags
- test_type
- test
- tool_config
- tool_product
- tool_type
- url
- api
- ui
- user
- unittests
- authorization
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | 14 | | |
18 | 15 | | |
19 | 16 | | |
20 | | - | |
21 | 17 | | |
22 | 18 | | |
23 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
29 | 38 | | |
30 | 39 | | |
31 | 40 | | |
| |||
61 | 70 | | |
62 | 71 | | |
63 | 72 | | |
64 | | - | |
65 | 73 | | |
66 | 74 | | |
67 | 75 | | |
| |||
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
78 | | - | |
79 | 86 | | |
80 | 87 | | |
81 | 88 | | |
| |||
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
89 | | - | |
90 | | - | |
91 | 96 | | |
92 | | - | |
93 | | - | |
94 | 97 | | |
95 | 98 | | |
96 | 99 | | |
97 | | - | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
48 | 47 | | |
| 48 | + | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
50 | 59 | | |
51 | 60 | | |
52 | 61 | | |
| |||
100 | 109 | | |
101 | 110 | | |
102 | 111 | | |
103 | | - | |
104 | 112 | | |
105 | 113 | | |
106 | 114 | | |
| |||
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
115 | | - | |
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| |||
123 | 130 | | |
124 | 131 | | |
125 | 132 | | |
126 | | - | |
127 | | - | |
128 | 133 | | |
129 | | - | |
130 | | - | |
131 | 134 | | |
132 | 135 | | |
133 | 136 | | |
134 | | - | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| |||
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | | - | |
20 | | - | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
11 | | - | |
12 | | - | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | | - | |
24 | | - | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 38 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1285 | 1285 | | |
1286 | 1286 | | |
1287 | 1287 | | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
| |||
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
15 | | - | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | | - | |
25 | | - | |
26 | 30 | | |
27 | | - | |
28 | | - | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
0 commit comments