1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-12 09:14:03 +00:00
Commit graph

1399 commits

Author SHA1 Message Date
lukinovec
c180c2c54e Use more accurate terminology 2025-07-31 16:54:08 +02:00
lukinovec
7bdbe9d880 Improve checking if tenant attribute is set 2025-07-31 16:52:06 +02:00
lukinovec
42c837d967 Refactor bootstrapper, provide more info in comments 2025-07-31 16:25:40 +02:00
lukinovec
81daa9d054 Simplify test 2025-07-31 16:16:32 +02:00
lukinovec
63bf4bf80e Clarify bootstrapper comments 2025-07-31 15:30:14 +02:00
lukinovec
bd44036a9f By default, only override the config if the override tenant property is set (otherwise, just skip the override and keep the default config value) 2025-07-31 15:15:33 +02:00
16ed2bcc8f Merge branch 'master' of github.com:archtechx/tenancy 2025-07-29 22:25:31 +02:00
0a48767c32 Bump jobpipeline dependency to rc6 2025-07-29 22:25:07 +02:00
lukinovec
475ea10ae9
Delete unused import (#1382) 2025-07-29 17:18:14 +02:00
lukinovec
b2f2669885
[4.x] Cloning: addTenantParameter(bool), domain(string|null) (#1374)
* Add test for the new clone action addTenantParameter property

* Add $addTenantParameter properyt to the clone action

* Fix code style (php-cs-fixer)

* Update clone action annotation

* Make addTenantParameter(false) sound by adding domain() logic to route cloning

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-07-29 17:17:32 +02:00
lukinovec
582243c53f Clarify test name 2025-07-29 13:22:02 +02:00
lukinovec
62a0e395c3 Delete redundant test, test the same logic in the one larger test 2025-07-29 13:13:31 +02:00
lukinovec
8cd35d3985 Add @see to bootstrapper docblock 2025-07-29 12:50:18 +02:00
lukinovec
ec4752881c Refactor bootstrapper, make comments more concise 2025-07-29 12:48:11 +02:00
lukinovec
a806df063d Stop using real domains in the tests 2025-07-29 12:25:02 +02:00
lukinovec
718afd3069 Simplify the slack channel usage test 2025-07-29 12:24:06 +02:00
lukinovec
a13110c880 Test real usage with slack channel (the bootstrapper updates the webhook used by the slack channel correctly) 2025-07-29 12:19:04 +02:00
lukinovec
b80d7b3996 Test real usage with storage path-based channels 2025-07-29 11:44:32 +02:00
lukinovec
50853a3c45 Test LogTenancyBootstrapper logic (low-level tests) 2025-07-29 10:59:56 +02:00
lukinovec
43cf6d2359 Merge branch 'master' into add-log-bootstrapper 2025-07-29 08:37:08 +02:00
0ef0104355 Add MariaDB database manager config 2025-07-28 17:08:07 +02:00
github-actions[bot]
96a05cdce8 Fix code style (php-cs-fixer) 2025-07-28 10:11:35 +00:00
lukinovec
01a06c9210 Add LogTenancyBootstrapper 2025-07-28 12:11:09 +02:00
62624275cc phpstan fix 2025-07-14 21:48:30 +02:00
91295f01e2 fix origin identification: parse hostname when full URL is used 2025-07-14 21:44:12 +02:00
d8af9b4b43 remove JobBatchBootstrapper 2025-07-10 01:08:49 +02:00
lukinovec
393f263f03
[4.x] Update route cloning example in TenancyServiceProvider stub (#1372)
* Update cloning example

* Delete double `//` from cloning example in TSP stub
2025-07-04 12:08:43 +02:00
lukinovec
4ead17a56b
[4.x] TableRLSManager refactor, comment constraints (#1354)
* Add option to provide constraint information in column comment

* Fix code style (php-cs-fixer)

* Correct comment functionality, add comment constraint exception

* Simplify and clarify comment-related TableRLSManager code

* Make path skipping logic more explicit

* Correct terminology, add test for throwing exceptions

* Fix code style (php-cs-fixer)

* Improve comments

* Refactor TableRLSManagerr (dynamic programming, deal with recursive relationships, determine shortest paths while generating the paths)

* Fix code style (php-cs-fixer)

* Improve TableRLSManager comments

* Test uncovered edge cases

* Improve code for determining the shortest path

* Improve readability

* Fix code style (php-cs-fixer)

* Update the tree terminology

* Use consistent shortest path terminology

* Improve comment

* Improve method name

* Simplify and clarify core shortest path generation test

* Clarify and simplify tests, add comments

* Delete excessive test

* Test data separation with comment constraints

* Use tenant id instead of getTenantKey()

* Make higher-level code clearer, improve comments

* Improve comments, delete excessive methods, make methods more concise, position helper methods more appropriately

* Fix code style (php-cs-fixer)

* Add a "single source of truth" for path array format, make lower-level code more concise, improve comments

* Fix code style (php-cs-fixer)

* Correct terminology and comments in TableRLSManager

* Correct terminology in table manager test file

* Improve comments and method name

* Fix typo

* bump php memory limit when running tests

* Delete findShortestPath, merge the code into shortestPathToTenantsTabke

* Minor shortestPathToTenantsTable improvement

* Improve docblocks,as discussed

* Move RLSCommentConstraintException to src/RLS/Exceptions

* Fully cover shouldSkipPathLeadingThrough in tests

* test improvements

* tests: add comment to clarify the chosen path

* formatting

* Fix typo

* Use `===` instead of `Str::is()`

* Refactor constraint formatting in TableRLSManager

* Fix code style (php-cs-fixer)

* Update key names of the formatted constraints

* Rename shouldSkipPathLeadingThrough() to shouldSkipPathLeadingThroughConstraint()

* misc improvements

* code improvements

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-07-03 21:12:04 +02:00
lukinovec
d1f12f594d
Instead of assigning $innerMiddleware during group MW unpacking, merge it (#1371) 2025-07-01 17:23:13 +02:00
lukinovec
1e926a1dde
[4.x] Route cloning refactor (#1353)
* Refactor cloning action, update tests

* Delete redundant "should not be cloned" part from shouldBeCloned()

* Use 'clone' instead of a universal route in tenant parameter removal test

* Improve comment

* Add test for cloneRoutesWithMiddleware(), correct existing tests

* Allow cloning specific routes by name

* Fix typo in CloneActionTest

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* clean up CloneRoutesAsTenant, add a todo

* phpstan

* Add test for handling 'clone'  in MW groups

* Improve regression test

* Improve regression test

* Handle nested cloning flags in CloneRoutesAsTenant

* Ignore routes that are already considered tenant routes from cloning, update test accordingly

* Clarify cloning logic

* CloneRoutesAsTenant cleanup

* Rewrite clone action annotation, fix fluent usage bug

* Improve tests (comments, use $tenant->id instead of $tenant->getTenantKey())

* Test that the clone action can be used fluently without issues now (could serve as a regression test for the routesToClone change in previous commit)

* Minor annotation improvements

* Improve route cloning action docblock

* Add note about clearing the $routesToClone property

* improve docblock

* clean up tests

* fix typo

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-07-01 00:32:42 +02:00
lukinovec
7e1fe075f4
[4.x] Test that global scopes on syncable models can break resource syncing, and that $scopeGetModelQuery can be used as a workaround for that (#1285)
* Add test for syncable models with global scopes

* minor fixes

* Make test clearer

* Improve test name

* Clarify scopeGetModelQuery test, document edge case

* Fix assertion

* Delete extra newline

* Update the scopeGetModelQuery test so that it tests a realistic case

* Clarify test

* cleanup

* Try simplifying the tests

* Revert change to test adding unnecessary complexity

* Make test clear, extensively commented and as simple as possible

* Delete unused import

* Make test clearer

* Polish comments

* Improve comment

* Explicitly reset global scopes on models in beforeEach()

* Simplify comments in test

* Revert changes in test

* add assertion

* add global scope reset to afterEach

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-06-26 13:39:11 +02:00
7481229063 revert regression in last commit, opt for a phpstan ignore instead 2025-06-19 00:12:38 +02:00
12fcbabd76 phpstan fix 2025-06-18 23:52:35 +02:00
551895d582 Merge branch 'master' into may25 2025-06-18 23:38:21 +02:00
e1fc0e107d remove ignition dependencies 2025-06-18 23:29:24 +02:00
lukinovec
2057e1e5ae
[4.x] Make forcing RLS configurable (#1293)
* Add `$forceRls` static property to tenants:rls

* Set `$forceRls` in tests where scoping is tested, add non-superuser, non-bypassrls table owner test

* Move DROP TABLE statement

* Remove try/catch

* Put DROP OWNED BY into try/catch

* Static property cleanup in afterEach

* Make with() matrix syntax more clear by using with() multiple times

* Fix typo, improve comment

* Move and update force RLS comment

* Add test for `$forceRls = false`, refactor BYPASSRLS test

* Update link in test comment

* Add a dataset for `$forceRls` in the table owner test, fix BYPASSRLS test

* Correct PR link comment

* minor fixes

* Add test that makes the bypassrls/forceRls behavior clear

* Delete redundant test

* cleanup

* Update tests/RLS/TableManagerTest.php

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-05 05:06:05 +02:00
e74e1f92e1
Make RouteMode enum backed (#1362) 2025-06-02 20:34:49 +02:00
lukinovec
f771aa8645
[4.x] Test that route model binding works correctly with path identification (#1360)
* Test that route model binding works with path identification (closure-based routes)

* Correct test name

* Update tests/PathIdentificationTest.php

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* make assertions more clear

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-06-02 19:05:17 +02:00
5f7fd38e5a
[4.x] URL generation, request data identification improvements (#1357)
* UrlGenerator: set defaults based on config; request data: move config to config file+resolver

* Claude code adjustments

* improve request data tests, simplify complex test in UrlGeneratorBootstrapperTest

* url generator test: test changing tenant parameter name

* request data identification: add tenant_model_column configuration

* defaultParameterNames -> passQueryParameter

* move comment

* minor refactor in PathIdentificationTest, expand CLAUDE.md to include early identification section

* Fix COLOR_FLAG

* improve test name

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* TenancyUrlGenerator: add a check for queryParameterName being null

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix code style (php-cs-fixer)

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-06-02 03:43:47 +02:00
f4cc99b317 fix phpstan 2025-05-29 18:39:05 +02:00
37f6260812 Add CLAUDE.md 2025-05-29 18:36:09 +02:00
lukinovec
588d1fcc0d
[4.x] Make TableRLSManager skip foreign keys with 'no-rls' comment right away (#1352)
* When a foreign key has no-rls comment (or no comment when scopeByDefault is false), skip path generation earlier

* Fix column definitions
2025-05-15 14:54:04 +02:00
27685ffe5a improve sample RootUrlBootstrapper config 2025-05-09 15:15:22 +02:00
lukinovec
dc90e60a2f
[4.x] Make ScopeSessions usable on universal routes (#1342)
* Skip ScopeSessions MW if the current context is central and the route is universal

* Add regressiont test

* Simplify code

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-04-04 03:15:37 +02:00
lukinovec
8cd15db1fc
[4.x] Make RemoveStorageSymlinksAction able to delete broken symlinks (#1323)
* Add regression test for removing invalid symlinks

* Move commented RemoveStorageSymlinks job to the DeletingTenant pipeline (better default - the symlinks will be removed *before* deleting tenant storage)

* Remove symlink validity check from symlinkExists() (only check for the symlink's existence)

* Delete complete todo0

* Make the symlink assertions more explicit

* update test name

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-03-18 21:27:27 +01:00
Alexandru Bucur
8d87ee9dfc
[4.x] Add ULIDGenerator (#1332)
* feat: introduce a simple ULID generator

* add test

---------

Co-authored-by: Samuel Štancl <samuel@archte.ch>
2025-03-18 19:00:35 +01:00
Sergio Peris
84a2863d2d
[4.x] Fix fully qualified name at TenancyServiceProvider.stub.php (#1334) 2025-03-18 18:56:29 +01:00
95dd906de2
[4.x] Make the ImpersonationToken model configurable (#1335)
* Make the ImpersonationToken model configurable, resolve #1315

* Add type definition

* Make phpstan happy
2025-03-18 18:42:08 +01:00
37a0f1a713
[4.x] Invalidate resolver cache on delete (#1329)
* Invalidate resolver cache on delete

* Fix code style (php-cs-fixer)

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-03-13 17:03:49 +01:00
8960a83047
[4.x] Laravel 12 support (#1321)
* Add Laravel 12 support, drop Laravel 11 support

* Fix RLS tree generation (specify schema name in generateTrees())

* ci fixes, use stable virtualcolumn version

---------

Co-authored-by: lukinovec <lukinovec@gmail.com>
2025-02-25 16:26:18 +01:00