-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3476 from GSA-TTS/main
- Loading branch information
Showing
27 changed files
with
811 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
-- WARNING | ||
-- Under PostgreSQL 12, the functions below work. | ||
-- Under PostgreSQL 14, these will break. | ||
-- | ||
-- Note the differences: | ||
-- | ||
-- raise info 'Works under PostgreSQL 12'; | ||
-- raise info 'request.header.x-magic %', (SELECT current_setting('request.header.x-magic', true)); | ||
-- raise info 'request.jwt.claim.expires %', (SELECT current_setting('request.jwt.claim.expires', true)); | ||
-- raise info 'Works under PostgreSQL 14'; | ||
-- raise info 'request.headers::json->>x-magic %', (SELECT current_setting('request.headers', true)::json->>'x-magic'); | ||
-- raise info 'request.jwt.claims::json->expires %', (SELECT current_setting('request.jwt.claims', true)::json->>'expires'); | ||
-- | ||
-- To quote the work of Dav Pilkey, "remember this now." | ||
|
||
-- We don't grant tribal access (yet) | ||
create or replace function api_v1_1_0_functions.has_tribal_data_access() | ||
returns boolean | ||
as $has_tribal_data_access$ | ||
DECLARE | ||
uuid_header UUID; | ||
key_exists boolean; | ||
BEGIN | ||
|
||
SELECT admin_api_v1_1_0_functions.get_api_key_uuid() INTO uuid_header; | ||
SELECT | ||
CASE WHEN EXISTS ( | ||
SELECT key_id | ||
FROM public.dissemination_TribalApiAccessKeyIds taaki | ||
WHERE taaki.key_id = uuid_header::TEXT) | ||
THEN 1::BOOLEAN | ||
ELSE 0::BOOLEAN | ||
END | ||
INTO key_exists; | ||
RETURN key_exists; | ||
END; | ||
$has_tribal_data_access$ LANGUAGE plpgsql; | ||
|
||
|
||
NOTIFY pgrst, 'reload schema'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
begin; | ||
|
||
do | ||
$$ | ||
begin | ||
DROP SCHEMA IF EXISTS api_v1_1_0 CASCADE; | ||
DROP SCHEMA IF EXISTS api_v1_1_0_functions CASCADE; | ||
|
||
if not exists (select schema_name from information_schema.schemata where schema_name = 'api_v1_1_0') then | ||
create schema api_v1_1_0; | ||
create schema api_v1_1_0_functions; | ||
|
||
grant usage on schema api_v1_1_0_functions to api_fac_gov; | ||
|
||
-- Grant access to tables and views | ||
alter default privileges | ||
in schema api_v1_1_0 | ||
grant select | ||
-- this includes views | ||
on tables | ||
to api_fac_gov; | ||
|
||
-- Grant access to sequences, if we have them | ||
grant usage on schema api_v1_1_0 to api_fac_gov; | ||
grant select, usage on all sequences in schema api_v1_1_0 to api_fac_gov; | ||
alter default privileges | ||
in schema api_v1_1_0 | ||
grant select, usage | ||
on sequences | ||
to api_fac_gov; | ||
end if; | ||
end | ||
$$ | ||
; | ||
|
||
-- This is the description | ||
COMMENT ON SCHEMA api_v1_1_0 IS | ||
'The FAC dissemation API version 1.0.3.' | ||
; | ||
|
||
-- https://postgrest.org/en/stable/references/api/openapi.html | ||
-- This is the title | ||
COMMENT ON SCHEMA api_v1_1_0 IS 'A RESTful API that serves data from the SF-SAC.'; | ||
|
||
commit; | ||
|
||
notify pgrst, | ||
'reload schema'; | ||
|
Oops, something went wrong.