-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Org page improvements #888
Conversation
C# Unit Tests52 tests 52 ✅ 5s ⏱️ Results for commit b62400f. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of tricky stuff in here. Keep it up! 👍
backend/LexBoxApi/GraphQL/CustomTypes/RefreshJwtOrgMembershipMiddleware.cs
Show resolved
Hide resolved
backend/LexBoxApi/GraphQL/CustomTypes/RefreshJwtOrgMembershipMiddleware.cs
Outdated
Show resolved
Hide resolved
I don't have time to think this through right now, but...I think we likely have a problem here. The project refresh middleware works by assuming that a user will only query projects that it is a member of. I'm only just realizing this, so I haven't analyzed wether you've considered this or not, but...I'm guessing the logic's not quite right. I'm guessing the Exception you got was, because your code refreshes the JWT much more often than desired. |
Right: this might cause refreshes more often than needed. But it limits itself to one refresh per query, at least. Still, that's more work than truly needed, you're right. I don't have time to rethink this today, though. |
Rebasing on top of new |
7f5bdfc
to
eaf6e8b
Compare
Dismissing Tim's review as he's away for three months; will request re-review from Kevin.
@rmunn I've made some changes to how we're returning orgs for permission issues. When querying the org list (default handling) only admins can query projects and members. Also per Tim's comment, we need to rework the logic of the refresh jwt code as a query returning an org does not mean the user should now have access to it, the way it's setup now I think it'll refresh any time a user visits the org list page. |
The new OrgPermissionTests all pass now. But look at commit 19eabe4, which is a deliberate bug. That change should have caused a test to fail, but it didn't. In order to make this change fail, we'll need a third project in our seeding data, one that is confidential but that the "editor" user is not a member of. Then that test will fail until commit 19eabe4 is reverted, thereby proving that the tests can catch the bug I deliberately introduced in 19eabe4. |
For the third project, it would be useful for it to be an empty project. I suggest we zip up the Actually, I'm starting to think that this should be tracked as its own issue. |
1c8567d
to
fdf965b
Compare
After #900 was merged, there was (as expected) a merge conflict in Taskfile.yml, so I rebased on top of the new state of |
Site admins can view any org page, but shouldn't see a "Leave Org" button unless they're actually members of the org.
Commented out for now because "orgs can own projects" PR needs to be merged before this will compile.
This will be useful for enforcing GQL permissions such as "non-members can only see the list of admins, members can see other members".
Public projects have isConfidential *false*, not true.
The "editor" user is a member of the test org; this test wants a non-member.
This proves that the test will catch this bug.
This proves that the test suite is now catching the bug.
Also include unit tests to prove that non-managers cannot see usernames.
The org members table doesn't need to show the "user is locked" or "email not verified" icons; those can be left on the admin dashboard. But we do want the org managers to be able to see members' usernames, since there may very well be guest users in the org with usernames but no email addresses, and org managers should be able to help them get Send/Receive configuration set up properly.
7b12448
to
8cc5e01
Compare
Currently I'm seeing a single unit test failure on my machine (as opposed to the three failing tests in the GHA workflow checks): Testing.ApiTests.AuthTests.CanUseBearerAuth fails with a 401 Unauthorized error. The logs show the following:
Parsing the jwt that the test is handling shows However, the same failure occurs when I run the tests on |
backend/LexBoxApi/GraphQL/CustomTypes/RefreshJwtOrgMembershipMiddleware.cs
Outdated
Show resolved
Hide resolved
Org page show shows the email/username column to org managers/admins, because we have decided that they're allowed to see it and have implemented GraphQL rules to that effect.
Org managers, like admins, should be able to see who created a guest user's account. We expose this in the UserModal by adding createdBy to the orgMemberById query.
Adding a third test project exposed a bug: if the org manager hovers over a confidential project that he's not a member of, then the GraphQL query for the project page will fail and it will show an error popup. After discussing this with @hahn-kev we decided that we're going to edit the project page query permissions to allow org admins to view projects owned by their org, at which point the error popup will no longer show. So we'll leave this bug in place for now, as we're going to fix it soon in a separate PR. @hahn-kev, I believe this is ready for a final review now. |
This is now tracked in #915, which I will work on next. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I requested a change which actually ends up simplifying some of the code.
We have that logic in PermissionService now, so let's use it.
We decided that people who aren't org members can still see the projects that they themselves are a member of, which means the rule for projects is the same for both members and non-members so the code gets simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me. There's still an unresolved conversation that requires a change. There's also some failing tests so you should look into those too, they're working on develop, so I'm not sure why they're failing here.
Now there's a single source of truth for the two middleware classes that need to reference it.
The LoginAs method needs to be virtual so that it can be mocked when non-integration tests are running, otherwise the mock will still try to log in to a server that isn't there.
Fixes #881.
Screenshots:
Org page members list as seen by non-member (shows only org admins):
Org page members list as seen by org admin (shows all members, but not emails since only site admins can see emails):
Org page members list as seen by site admin (shows emails, also shows all members even though site admin isn't an org member):