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

Make Scopes Easier to Use in the UI #2741

Merged
merged 10 commits into from
Mar 3, 2023
Merged

Make Scopes Easier to Use in the UI #2741

merged 10 commits into from
Mar 3, 2023

Conversation

pattisdr
Copy link
Contributor

@pattisdr pattisdr commented Mar 2, 2023

Closes #2716

Code Changes

  • Dynamically create a ScopeRegistryEnum from the list of scopes
    • Make this the "type" when getting user permission scopes
  • Delete custom validation for scopes now that we can use the enum
  • If scope registry changes and user has a scope that no longer exists, filter that out instead of failing on access.
  • Add a "total" scopes property that sums the scopes the user has directly along with scopes they have via roles.
  • Add logic so that if we remove scopes from the scope registry, the enum doesn't break when trying to load the current user's scopes

Steps to Confirm

  • Login in as a root user
  • Create another user with limited scopes
  • Verify that UI loads properly
  • Login as the created user
  • Verify UI loads properly
  • Navigate to the get user permissions endpoint and note the "total scopes" key
  • Navigate to http://localhost:8080/openapi.json and note the ScopeRegistryEnum

Pre-Merge Checklist

Description Of Changes

Return a scopes enum so the UI can use this, as well as return "total scopes" - scopes that the user has via their roles or that they were assigned directly.

- Dynamically create a ScopeRegistryEnum from the list of scopes
- Make this the "type" when getting user permission scopes
- Delete custom validation for scopes now that we can use the enum
- If scope registry changes and user has a scope that no longer exists, filter that out instead of failing on access.
@cypress
Copy link

cypress bot commented Mar 2, 2023

Passing run #604 ↗︎

0 3 0 0 Flakiness 0

Details:

Merge a01a386 into 663bc54...
Project: fides Commit: 3c62eb8c6e ℹ️
Status: Passed Duration: 00:39 💡
Started: Mar 3, 2023 8:53 PM Ended: Mar 3, 2023 8:53 PM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@pattisdr pattisdr marked this pull request as ready for review March 3, 2023 01:05
@codecov
Copy link

codecov bot commented Mar 3, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change

Comparison is base (663bc54) 86.58% compared to head (a01a386) 86.59%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2741   +/-   ##
=======================================
  Coverage   86.58%   86.59%           
=======================================
  Files         290      290           
  Lines       16216    16224    +8     
  Branches     2060     2062    +2     
=======================================
+ Hits        14041    14049    +8     
  Misses       1792     1792           
  Partials      383      383           
Impacted Files Coverage Δ
.../fides/api/ops/api/v1/endpoints/oauth_endpoints.py 92.47% <ø> (ø)
src/fides/api/ops/api/v1/scope_registry.py 100.00% <100.00%> (ø)
src/fides/api/ops/schemas/user_permission.py 100.00% <100.00%> (ø)
src/fides/lib/models/fides_user_permissions.py 100.00% <100.00%> (ø)
src/fides/lib/oauth/roles.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@allisonking allisonking left a comment

Choose a reason for hiding this comment

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

💯

src/fides/api/ops/api/v1/scope_registry.py Show resolved Hide resolved
src/fides/api/ops/schemas/user_permission.py Show resolved Hide resolved
src/fides/api/ops/api/v1/scope_registry.py Show resolved Hide resolved
src/fides/api/ops/schemas/user_permission.py Show resolved Hide resolved
# Conflicts:
#	CHANGELOG.md
#	src/fides/api/ops/api/v1/scope_registry.py
#	tests/ops/api/v1/endpoints/test_user_permission_endpoints.py
@pattisdr pattisdr merged commit 2afc8b6 into main Mar 3, 2023
@pattisdr pattisdr deleted the fides_2716_scopes_enum branch March 3, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Backend] Make Scopes/Roles easier to use in the UI
2 participants