fix: prevent unauthorised access from group permissions - #5865
fix: prevent unauthorised access from group permissions#5865matthewelwell wants to merge 15 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
Docker builds report
|
There was a problem hiding this comment.
I'm not entirely convinced that the extra checks that I've added here are the most optimal way of adding this logic, but I couldn't find a single entrypoint to the permissions service which would allow me to add it.
Keen to get @gagantrivedi 's opinion on this topic.
There was a problem hiding this comment.
Yeah, doesn't look like there is a better way
| queryset = user_permission_group_membership_model.objects.exclude( | ||
| ffadminuser__organisations=F("userpermissiongroup__organisation") | ||
| ) | ||
| logger.info("Removing orphan group memberships.", num_orphan_memberships=queryset.count()) |
There was a problem hiding this comment.
I've purposefully added one such record to the staging database. We should verify in the logs on staging that this migration behaves as we expect before running the migration in production.
c77fb26 to
46eeb6f
Compare
…nto fix/prevent-unauthorised-access-from-group-permissions
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## test/combine-staff-and-test-user-fixtures #5865 +/- ##
==========================================================================
Coverage 97.82% 97.83%
==========================================================================
Files 1258 1260 +2
Lines 44846 44920 +74
==========================================================================
+ Hits 43872 43946 +74
Misses 974 974 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Superseded by #5893 |
Changes
This PR prevents users that were part of groups in organisations that they no longer belong to from accessing the resources in that organisation.
From testing, the only way that this was possible in the first place was if the user was removed from the organisation in one of the following non-standard ways:
Note that this PR also includes a (tested) migration to remove any users from groups in organisations they do not belong to.
How did you test this code?
Added a lot of new unit tests.