Skip to content

fix: prevent unauthorised access from group permissions - #5893

Merged
matthewelwell merged 11 commits into
mainfrom
origin/fix/prevent-unauthorised-access-from-group-permissions-v2
Aug 20, 2025
Merged

fix: prevent unauthorised access from group permissions#5893
matthewelwell merged 11 commits into
mainfrom
origin/fix/prevent-unauthorised-access-from-group-permissions-v2

Conversation

@matthewelwell

@matthewelwell matthewelwell commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

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:

  • The user was removed via django admin
  • The user was removed as part of the logic to remove all users but the first one when a subscription is cancelled or downgraded

Note that this PR also includes a (tested) migration to remove any users from groups in organisations they do not belong to.

Also see #5865 for additional context (this PR was created to avoid git pain after rebase + squash)

How did you test this code?

Added a lot of new unit tests.

@vercel

vercel Bot commented Aug 5, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Aug 5, 2025 1:13pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Aug 5, 2025 1:13pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Aug 5, 2025 1:13pm

@github-actions github-actions Bot added api Issue related to the REST API fix labels Aug 5, 2025
@codecov

codecov Bot commented Aug 5, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (63f943a) to head (8511f20).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5893   +/-   ##
=======================================
  Coverage   97.82%   97.83%           
=======================================
  Files        1258     1260    +2     
  Lines       44846    44919   +73     
=======================================
+ Hits        43872    43946   +74     
+ Misses        974      973    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added fix and removed fix labels Aug 5, 2025
@matthewelwell
matthewelwell marked this pull request as ready for review August 5, 2025 13:26
@matthewelwell
matthewelwell requested a review from a team as a code owner August 5, 2025 13:26
@matthewelwell
matthewelwell requested review from khvn26 and removed request for a team August 5, 2025 13:26
@github-actions github-actions Bot added fix and removed fix labels Aug 5, 2025
@github-actions

github-actions Bot commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-5893 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-5893 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api:pr-5893 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api-test:pr-5893 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-private-cloud:pr-5893 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-5893 Finished ✅ Results

@matthewelwell matthewelwell changed the title fix: prevent unauthorised access from group permissions (cleaned) fix: prevent unauthorised access from group permissions Aug 5, 2025
@matthewelwell
matthewelwell merged commit 18f3f09 into main Aug 20, 2025
46 checks passed
@matthewelwell
matthewelwell deleted the origin/fix/prevent-unauthorised-access-from-group-permissions-v2 branch August 20, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants