Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace role system (RBAC) with permissions-based DB roles #14905

Merged
merged 20 commits into from
Apr 11, 2024

Conversation

AlanCoding
Copy link
Member

SUMMARY

This replaces #14735 as we have introduced a feature branch for this purpose.

This makes use of ansible/django-ansible-base#45 and the intent is to have that merged before this.

New endpoints are exposed from DAB. These are

  • role definitions
  • role user assignments
  • role team assignments

The routers/views/serializers for these new endpoints live in DAB, not in this patch. This is mostly concerned with the "translation" layer to make the new roles look kind of like the old roles. Generally this is intended to be a backward-compatible change.

ISSUE TYPE
  • New or Enhanced Feature
COMPONENT NAME
  • API
ADDITIONAL INFORMATION

@github-actions github-actions bot added component:api component:awx_collection issues related to the collection for controlling AWX component:docs dependencies Pull requests that update a dependency file labels Feb 20, 2024
@dmzoneill dmzoneill marked this pull request as draft February 21, 2024 13:14
@AlanCoding AlanCoding changed the title Replace role system with permissions-based DB roles Replace role system (RBAC) with permissions-based DB roles Mar 4, 2024
@AlanCoding AlanCoding force-pushed the feature_dab_rbac branch 2 times, most recently from 7f6615a to e3bc4a0 Compare March 6, 2024 17:47
@@ -536,10 +540,12 @@ class InstanceGroupAccessList(ResourceAccessList):


class InstanceGroupObjectRolesList(SubListAPIView):
deprecated = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we really going to deprecate everything? That seems pretty hostile to community users.

(also, this one seems to have deprecated = True twice.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talking about deprecation, if I understood you correctly access_list should be marked as deprecated as well right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put up #15068, which should address the things mentioned in both of the above 2 comments.

And yes, these will be deprecated. Obviously we won't just go break the UI. We will push the new UI to the community somehow and stop maintaining the old UI. Some time after that, yes, we will remove these endpoints, and we will delete the old Role tables that are used for the backward compatibility. Everything you could do with these you can do with the new endpoints.

@AlanCoding AlanCoding force-pushed the feature_dab_rbac branch 2 times, most recently from ce7db57 to f56bf6f Compare April 10, 2024 20:26
Develop ability to list permissions for existing roles

Create a model registry for RBAC-tracked models

Write the data migration logic for creating
  the preloaded role definitions

Write migration to migrate old Role into ObjectRole model

This loops over the old Role model, knowing it is unique
  on object and role_field

Most of the logic is concerned with identifying the
  needed permissions, and then corresponding role definition

As needed, object roles are created and users then teams
  are assigned

Write re-computation of cache logic for teams
  and then for object role permissions

Migrate new RBAC internals to ansible_base

Migrate tests to ansible_base

Implement solution for visible_roles

Expose URLs for DAB RBAC
…tem (#14963)

* Add new enablement settings from DAB RBAC

* Initial implementation of system auditor as role without testing

* Fix system auditor role, remove duplicate assignments

* Make the system auditor role managed

* Flake8 fix

* Remove another thing from old solution

* Fix a few test failures

* Add extra setting to disable custom system roles via API

* Add test for custom role prohibition
AlanCoding and others added 13 commits April 11, 2024 13:13
Fix migration for created and modified field changes
Fix server error from delete capability of approvals
* Generalize can_delete solution, use devel DAB

* Fix bug where model was used instead of model_name

* Linter fixes
* Remove duplicate access_list entries for direct team access

* Revert test changes for superuser in access_list
Adds new modules for CRUD operations on the
following endpoints:

- api/v2/role_definitions
- api/v2/role_user_assignments
- api/v2/role_team_assignments

Note: assignment is Create or Delete only

Additional changes:
- Currently DAB endpoints do not have "type"
field on the resource list items. So this modifies
the create_or_update_if_needed to allow manually
specifying item type.

Signed-off-by: Seth Foster <[email protected]>
Tweaks to reflect what endpoints are deprecated
…15067)

* Fix bug where team could not be given read_role to other team

* Avoid unwanted triggers of parentage granting

* Restructure signal structure

* Fix another bug unmasked by team member permission fix

* Changes to live with test writing

* Use equality as opposed to string "in"

from Seth in review comment

Co-authored-by: Seth Foster <[email protected]>

---------

Co-authored-by: Seth Foster <[email protected]>
…#15087)

* Rename managed role definitions, and move migration logic here

* Fix naming capitalization
Update related name to reflect upstream DAB change
@AlanCoding AlanCoding merged commit 390c2d8 into devel Apr 11, 2024
24 of 25 checks passed
@AlanCoding AlanCoding deleted the feature_dab_rbac branch April 11, 2024 18:59
@tvo318 tvo318 mentioned this pull request Apr 23, 2024
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:api component:awx_collection issues related to the collection for controlling AWX component:docs dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants