Skip to content
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

[4.x] Make forcing RLS configurable #1293

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

lukinovec
Copy link
Contributor

This PR adds the $forceRls static property to the tenants:rls command.

If $forceRls is true (default), the table owners won't be able to query their own tables (unless the owners have the BYPASSRLS privilege). If the property is set to false, table owners will bypass RLS, allowing them to query the owned tables.

Copy link

codecov bot commented Jan 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.04%. Comparing base (0e223e0) to head (3fabdf8).
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1293      +/-   ##
============================================
+ Coverage     84.68%   85.04%   +0.35%     
- Complexity     1036     1067      +31     
============================================
  Files           175      176       +1     
  Lines          3043     3163     +120     
============================================
+ Hits           2577     2690     +113     
- Misses          466      473       +7     

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

@@ -21,6 +21,7 @@
use Stancl\Tenancy\Database\Exceptions\RecursiveRelationshipException;

beforeEach(function () {
CreateUserWithRLSPolicies::$forceRls = true;
Copy link
Member

Choose a reason for hiding this comment

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

Also reset this in afterEach

Copy link
Member

Choose a reason for hiding this comment

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

Same thing in the other test files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 267 to 270
})->with(
[true, false],
[true, false],
);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
})->with(
[true, false],
[true, false],
);
})->with(
[true, false],
[false, true],
);

or

Suggested change
})->with(
[true, false],
[true, false],
);
})->with([true, false])->with([true, false]);

Copy link
Member

Choose a reason for hiding this comment

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

Hmm or is the syntax that it builds a matrix from those arrays? I see in another dataset it's used that way.

Probably change these to use two with() calls to make that more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm or is the syntax that it builds a matrix from those arrays?

Yeah

Copy link
Contributor Author

@lukinovec lukinovec Jan 14, 2025

Choose a reason for hiding this comment

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

Used the two with() calls

1f41a8a

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

Successfully merging this pull request may close these issues.

2 participants