1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-06-21 19:44:04 +00:00
tenancy/resources/boost/skills/laravel-tenancy/references/rls.md

776 B

PostgreSQL RLS Reference

Use this when implementing single-database PostgreSQL row-level security.

Source Files

  • src/Bootstrappers/PostgresRLSBootstrapper.php
  • src/RLS/*
  • src/Database/Concerns/RLSModel.php
  • src/Commands/CreateUserWithRLSPolicies.php
  • tests/RLS/*

Config

  • rls.manager
  • rls.user.username
  • rls.user.password
  • rls.session_variable_name
  • PostgresRLSBootstrapper in bootstrappers

Command

php artisan tenants:rls
php artisan tenants:rls --force

Rules

  • Use PostgreSQL and single-database tenancy.
  • Session variable name must be namespaced, for example my.current_tenant.
  • RLS user is one tenant database user for all tenants, not one user per tenant.
  • Test policies on every tenant-owned table.