Skip to content

feat: add organization-scoped permission checks to deployment settings #14063

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

Merged
merged 20 commits into from
Aug 6, 2024

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Jul 31, 2024

Part of #13915

You should be able to see the all the links on the settings page to which you have access, and those pages should react appropriately (like groups should only have the create group button if you have permission, etc).

This only affects multi-org. There should be no change if not multi-org.

Copy link

alwaysmeticulous bot commented Jul 31, 2024

🤖 Meticulous spotted visual differences in 321 of 735 screens tested: view and approve differences detected.

Last updated for commit 5a547fc. This comment will update as new commits are pushed.

@code-asher code-asher force-pushed the asher/org-permissions branch 2 times, most recently from ad74fcf to f6dfce0 Compare July 31, 2024 01:49
Copy link
Collaborator

@BrunoQuaresma BrunoQuaresma left a comment

Choose a reason for hiding this comment

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

I left a few comments, and I see there are a few TODOs in the codebase. Do you plan to finish these TODOs during the current work or address them later? If later, would it make sense to transform the important ones into issues?

PS: I'm going to QA this at some point today.

@BrunoQuaresma
Copy link
Collaborator

I QAed the changes and they look good, but I think it could be better if you have specific areas where I should look for issues. Since it is a "draft" PR I'm not approving it for now, but feel free to request another review at any time.

@code-asher
Copy link
Member Author

code-asher commented Jul 31, 2024

@BrunoQuaresma Thank you for giving it an early look! I still need to add/update some tests/Storybooks and then I think it will be good to go. I will make some notes on the kinds of things that need to be QA'd.

As for the TODOs, I will check with Kira and make issues for the ones she thinks makes sense.

@code-asher code-asher force-pushed the asher/org-permissions branch 6 times, most recently from 8a411e3 to b8bffa5 Compare August 1, 2024 01:37
@code-asher
Copy link
Member Author

All right, I updated the tests and added stories but I had to break out into some views to do that. The code is mostly unchanged but the diff will look a a bit large.

So generally here is what I have been testing:

  • A site-wide admin should see and be able to edit all the deployment settings and organizations.
  • A site-wide auditor should see the audit logs for the default org. And the deployment settings apparently, but not the licenses or appearance. They can also see the members and groups for the default orgs but not edit either.
  • An org admin should only be able to edit the settings, members, and groups of orgs of which they are an admin, and should see the audit logs of their orgs as well.
  • All of the above should be able to view users site-wide. But only the admin can add new users.
  • An org auditor should only be able to see the audit logs for their own orgs. But no access to the members or groups of the org.
  • Plain members will not see any deployment dropdown at all (just like before).
  • If you have multi-org disabled or are not licensed for multi-org then everything should look and work exactly the way it was before.

NOTE: The audit log will not work right now for org admins/auditors, but they will once Steven's PR is merged so I will leave this in a draft until that is done then I will mark ready and request a review. <3

@code-asher code-asher changed the title feat: add organization-scoped permissions checks feat: add organization-scoped permissions checks to settings page Aug 1, 2024
@code-asher code-asher force-pushed the asher/org-permissions branch from b8bffa5 to 19f3895 Compare August 1, 2024 02:12
@code-asher code-asher changed the title feat: add organization-scoped permissions checks to settings page feat: add organization-scoped permissions checks to deployment settings Aug 1, 2024
@code-asher code-asher force-pushed the asher/org-permissions branch from 19f3895 to 584bd19 Compare August 1, 2024 02:15
@code-asher code-asher changed the title feat: add organization-scoped permissions checks to deployment settings feat: add organization-scoped permission checks to deployment settings Aug 1, 2024
Seems like all the other frontend variables use the `view` syntax.
Arguably we should use `read` to match the backend, but `view` does seem
more UI-like.
All the checks now require both the experiment and license.

I also renamed the variable canViewOrganizations everywhere for
consistency.
You will only see the button if you can create a group in that org.

Now that the old site-wide group permission is unused, remove it.
Since in addition to deployment settings this page now also includes
users, audit logs, groups, and orgs.

Since you might not be able to fetch deployment values, move all the
loaders to the individual pages instead of in the wrapping layout.
We only use this layout when multi-org is enabled, so no need to run the
check a second time.
An auditor for example appears to have the view deployment values
permission but cannot view licenses.
@code-asher code-asher force-pushed the asher/org-permissions branch from 584bd19 to 185f2c0 Compare August 1, 2024 19:34
@code-asher code-asher marked this pull request as ready for review August 1, 2024 20:11
@code-asher
Copy link
Member Author

Should be good to go now!

@code-asher code-asher force-pushed the asher/org-permissions branch 2 times, most recently from ccb05b8 to 72bf345 Compare August 1, 2024 22:33
@code-asher code-asher force-pushed the asher/org-permissions branch from 72bf345 to d7afcfc Compare August 1, 2024 22:35
@BrunoQuaresma
Copy link
Collaborator

BrunoQuaresma commented Aug 5, 2024

I completed the QA and I found a few bugs. I think these bugs are not blockers so I'm approving the PR. Would be nice, and safe, to have someone else QAing this PR since it is quite large and touches some important places. Good work!

  • ✅ A site-wide admin should see and be able to edit all the deployment settings and organizations.
  • ❌ A site-wide auditor should see the audit logs for the default org. And the deployment settings apparently, but not the licenses or appearance. They can also see the members and groups for the default orgs but not edit either.
  • ⚠️ An org admin should only be able to edit the settings, members, and groups of orgs of which they are an admin, and should see the audit logs of their orgs as well.
  • ✅ All of the above should be able to view users site-wide. But only the admin can add new users.
  • ✅ An org auditor should only be able to see the audit logs for their own orgs. But no access to the members or groups of the org.
  • ✅ Plain members will not see any deployment dropdown at all (just like before).
  • ✅ If you have multi-org disabled or are not licensed for multi-org then everything should look and work exactly the way it was before.
  1. As an auditor, I was able to see the licenses.
Screenshot 2024-08-05 at 10 24 55 Screenshot 2024-08-05 at 10 26 45
  1. As an auditor, I'm getting stuck on the audit logs page. I can't see the other org options.
Screen.Recording.2024-08-05.at.10.28.03.mov
  1. As org admin, I was able to remove the owner from the members. I don't think admins should have the right to remove admins or any other higher user level.

@code-asher
Copy link
Member Author

code-asher commented Aug 5, 2024

Thank you for the thorough testing!!

As an auditor, I was able to see the licenses.

This should be fixed! Looks like you were on an older commit.

As an auditor, I'm getting stuck on the audit logs page. I can't see the other org options

Huh, weird I was not able to reproduce with a site-wide admin. I will poke into it more. Actually, could be due to being on an older commit, I did make some auditor changes. But see below, I removed the redirect entirely, but I think we need to design a better page for when the user has no edit permissions eventually.

As org admin, I was able to remove the owner from the members. I don't think admins should have the right to remove admins or any other higher user level.

That does seem weird, let me check with the backend folks. I will follow up with another PR if this needs to change. Looks like this is OK, owners can still do everything even if removed from an org, so it is mostly just up to the org admin if they want the owner in the member list or not.

@code-asher
Copy link
Member Author

code-asher commented Aug 5, 2024

I changed the automatic redirect for auditors, so now it just says "you have no permissions to edit" if there are no permissions instead of trying to redirect to the audit log. I think we will probably want to consider a better design for this though. I updated the ticket to reflect needing a decision on this.

@code-asher code-asher force-pushed the asher/org-permissions branch 4 times, most recently from 1d9ad8a to 01c4b19 Compare August 6, 2024 00:46
The 0000 syntax does not work, it has to be the actual org ID.

Technically this is probably not necessary since it means only admins
can create groups which was already the case, but I think being explicit
about the org we are checking is a good idea, even if these pages will
eventually go away in favor of the multi-org ones.
I think this needs a proper design/decision.
@code-asher code-asher force-pushed the asher/org-permissions branch from 01c4b19 to e58b032 Compare August 6, 2024 00:54
Originally I thought I should update these to use the org-based
permissions query but I think maybe I should scope my changes to just
the multi-org settings page and leave the old pages alone for now.
I think the "you do not have permission to edit" message might make it
sound like you can do nothing at all with the org, but it might be that
you can edit members and groups, just not the org settings.

So, instead, show the org settings but disable the form if you cannot
edit.  Probably there is still a better design but maybe this is OK for
now.
@code-asher
Copy link
Member Author

code-asher commented Aug 6, 2024

Just FYI I reverted two changes to the old groups and users pages, I felt like they were out of scope for this PR and I did not directly call them out in the list of stuff to test.

I also changed the org settings page to show an ineditable form instead of a big "you cannot edit this org" message but I will get a proper design for this page when a user has no permissions later.

@code-asher code-asher merged commit 097f739 into main Aug 6, 2024
34 checks passed
@code-asher code-asher deleted the asher/org-permissions branch August 6, 2024 01:55
@github-actions github-actions bot locked and limited conversation to collaborators Aug 6, 2024
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