Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Reflect auth0 roles in VIAL #660

Merged
merged 8 commits into from
Jun 14, 2021
Merged

Reflect auth0 roles in VIAL #660

merged 8 commits into from
Jun 14, 2021

Conversation

ugotsoul
Copy link
Contributor

@ugotsoul ugotsoul commented Jun 10, 2021

Part of #610 (comment)

I tested this locally, by adding / removing "WB Trainee" and other auth0 roles to my user.

Expected behavior:

  • User's who are staff are getting flagged correctly
  • All auth0 roles will be reflected as a group that the user model belongs to
  • Auth0 roles that are reflected are environment specific: STAGING or local/prod
  • Auth0 roles are also reflected on the associated Reporter model of a User, if it exists
  • Group membership is updated in maybe a brutish way, since the auth0 only knows all the current roles. Hoping to solve this in New auth0 role VIAL WB Limited is not displaying in the Reporters page #633

How to test:

- filter groups by environment
- update env specific groups on user model
- add readability to auth0 roles on reporter model
AUTH0_ROLES_TO_REFLECT = {
"Vaccinate CA Staff",
"VIAL super-user",
AUTH0_ROLES_STAFF = {
Copy link
Contributor Author

@ugotsoul ugotsoul Jun 10, 2021

Choose a reason for hiding this comment

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

Did I add all the staff roles? 🤔

@ugotsoul ugotsoul marked this pull request as draft June 10, 2021 22:38
@codecov
Copy link

codecov bot commented Jun 11, 2021

The author of this PR, ugotsoul, is not an activated member of this organization on Codecov.
Please activate this user on Codecov to display this PR comment.
Coverage data is still being uploaded to Codecov.io for purposes of overall coverage calculations.
Please don't hesitate to email us at [email protected] with any questions.

@ugotsoul ugotsoul marked this pull request as ready for review June 11, 2021 02:50
@ugotsoul ugotsoul requested a review from simonw June 11, 2021 02:50
@ugotsoul
Copy link
Contributor Author

Oh yeah, one thing I'll need to do is update all the reports and locations that were made by wb trainee's to be pending review (after coordinating with the wb'ing team to make sure they didn't approve these or not!)

group.user_set.add(user)
else:
group.user_set.remove(user)

# Note: Not all users are reporters
reporter_qs = Reporter.objects.filter(user=user)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use reporter = Reporter.objects.filter(user=user).first() here and it will either return a reporter or return None - which means you can then do if reporter: later on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TY! I totally forgot about this.

@simonw
Copy link
Collaborator

simonw commented Jun 14, 2021

Looks good to me - let's get this on staging and test it there.

@simonw simonw merged commit 691ed62 into main Jun 14, 2021
@ugotsoul
Copy link
Contributor Author

ugotsoul commented Jun 14, 2021

Testing on staging with my regular account ([email protected]) and got a bit worried I couldn't see admin pages, but I realized this was because there were no permissions assigned to these staging groups (whew!). https://vial-staging.calltheshots.us/dashboard/groups-and-permissions/

@ugotsoul
Copy link
Contributor Author

ugotsoul commented Jun 14, 2021

@simonw would you be able to add permissions for these groups:

  • Vaccinate CA Staff STAGING
  • VIAL data corrections STAGING
  • VIAL service account STAGING
  • VIAL super-user STAGING

since I'm locked out of viewing/editing group permissions on staging? Hopefully you are still logged into staging 🙏🏾

@ugotsoul
Copy link
Contributor Author

I got super user status and I was able to view groups again! I'm adding permissions to those groups above and also added a WB Trainee STAGING role for testing.

@ugotsoul
Copy link
Contributor Author

I logged out/in after assigning WB Trainee STAGING and have this group displayed in my chosen groups and it is listed in the Groups page. 🙌🏾

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants