Commit f674f41
authored
AAP-50803 500 server error when creating a custom role missing the "View" permission (ansible#822)
Fix AAP-50803: prevent 500 on custom roles missing “view” for remote
models by adding verbose_name to StandinMeta
- a safe fallback in validator;
- include regression test.
### Steps to Test
1. Create a new role at
[api/access/roles/create](http://localhost:44926/access/roles/create)
### Expected Results
Error message:
`Permissions for model inventory needs to include view, got ....`
### Root cause
Remote stand‑in metadata did not define `verbose_name`, and the
validator assumed it existed.
### Fix
1) Remote metadata enhancement
- Add `verbose_name` to `StandinMeta` (derived from `model_name`,
humanized/title‑cased). Optionally add `verbose_name_plural`.
2) Validator hardening
- In `check_view_permission_criteria`, safely obtain a model label via:
- `getattr(cls._meta, "verbose_name", getattr(cls._meta, "model_name",
"model"))`
- Use this label in the error to avoid `AttributeError`.
### Result
- The API now returns HTTP 400 with a clear validation message
indicating that the `view` permission is required for the target model,
instead of a server error.
### Manual verification
How to verify in the AAP UI
1. Sign in to the AAP web UI.
2. Navigate to Access Management → Roles.
3. Click “Create role”.
4. Enter values for Name, Display name, and Description.
5. Click “Add permission” but do not specify `view`.
6. Choose a remote content type (e.g., Service “AWX” → Resource
“Inventory” or another remote model).
7. For Actions, select only “Change” (or any non‑View action) and do not
add the corresponding “View” action for that same model.
8. Click “Save”.
9. Expected: The role is not created and an error is shown indicating
the View permission is required for that model.
(Optional: In browser DevTools → Network, the POST to
/api/gateway/v1/role_definitions/ returns HTTP 400 with the same
message.)1 parent d60e4be commit f674f41
File tree
3 files changed
+63
-3
lines changed- ansible_base/rbac
- test_app/tests/rbac/api
3 files changed
+63
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | | - | |
| 135 | + | |
| 136 | + | |
138 | 137 | | |
139 | 138 | | |
140 | 139 | | |
| |||
| 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 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
0 commit comments