Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (25 sloc) 1.01 KB
drop schema if exists request cascade;
create schema request;
grant usage on schema request to public;
create or replace function request.env_var(v text) returns text as $$
select current_setting(v, true);
$$ stable language sql;
create or replace function request.jwt_claim(c text) returns text as $$
select request.env_var('request.jwt.claim.' || c);
$$ stable language sql;
create or replace function request.cookie(c text) returns text as $$
select request.env_var('request.cookie.' || c);
$$ stable language sql;
create or replace function request.header(h text) returns text as $$
select request.env_var('request.header.' || h);
$$ stable language sql;
create or replace function request.user_id() returns int as $$
select
case coalesce(request.jwt_claim('user_id'),'')
when '' then 0
else request.jwt_claim('user_id')::int
end
$$ stable language sql;
create or replace function request.user_role() returns text as $$
select request.jwt_claim('role')::text;
$$ stable language sql;
You can’t perform that action at this time.