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

fix: define search path in auth functions #1636

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: update migration for setting search path on auth functions
  • Loading branch information
kangmingtay committed Jun 25, 2024
commit 9bfcd8232e8ae0b2e8ed1eeed6a0cca6b495acf4
10 changes: 8 additions & 2 deletions migrations/20240612114525_set_search_path.up.sql
Original file line number Diff line number Diff line change
@@ -6,15 +6,21 @@ begin
returns uuid
set search_path to ''
as $func$
select nullif(current_setting('request.jwt.claim.sub', true), '')::uuid;
select coalesce(
nullif(current_setting('request.jwt.claim.sub', true), ''),
(nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'sub')
)::uuid
$func$ language sql stable;

-- auth.role() function
create or replace function {{ index .Options "Namespace" }}.role()
returns text
set search_path to ''
as $func$
select nullif(current_setting('request.jwt.claim.role', true), '')::text;
select coalesce(
nullif(current_setting('request.jwt.claim.role', true), ''),
(nullif(current_setting('request.jwt.claims', true), '')::jsonb ->> 'role')
)::text
$func$ language sql stable;

-- auth.email() function
Loading