mansueli@rls_helpers

v1.0.0Created 7 months agoBy mansueli

RLS Helpers

This is an extension with convenience functions to help test and simulate RLS policies within the database.

You can use use it to get RLS context within direct database access or with Supavisor:

Usage

You can simulate log in as an user with the following:

Login as user:

BEGIN;
CALL auth.login_as_user('rodrigo@contoso.com');
SELECT * FROM profiles;
COMMIT;

Anon access:

BEGIN;
CALL auth.login_as_anon();
SELECT * FROM profiles;
COMMIT;

Logout:

BEGIN;
CALL auth.login_as_user('rodrigo@contoso.com');
SELECT * FROM profiles;
CALL auth.logout();
-- You are back to postgres role here:
SELECT * FROM profiles;
COMMIT;

Install

  1. Install the dbdev package manager
  2. Install the package:
select dbdev.install('mansueli@rls_helpers');
create extension "mansueli@rls_helpers"
    version '1.0.0';

Downloads

  • 0 all time downloads
  • 0 downloads in the last 30 days
  • 0 downloads in the last 90 days
  • 0 downloads in the last 180 days