Skip to main content

jit_access

Creates, updates, deletes, gets or lists a jit_access resource.

Overview​

Namejit_access
TypeResource
Idsupabase.database.jit_access

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectrefMappings of roles a user can assume in the project database
createinsertref, role, rhostAuthorizes the request to assume a role in the project database
updateupdateref, user_id, rolesModifies the roles that can be assumed and for how long
deletedeleteuser_id, refRemove JIT mappings of a user, revoking all JIT database access

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
refstringSupabase project reference (the Project ID shown in the dashboard under Settings -> General; 20 lowercase letters). Resolved from the SUPABASE_PROJECT_ID environment variable when it is set (x-stackQL-envVar); otherwise it must be supplied on every project-scoped query as WHERE ref = '<ref>'. A WHERE value always takes precedence over the environment. (x-stackQL-envVar: SUPABASE_PROJECT_ID)
user_idstring (uuid)

SELECT examples​

Mappings of roles a user can assume in the project database

SELECT
*
FROM supabase.database.jit_access
WHERE ref = '{{ ref }}' -- required unless SUPABASE_PROJECT_ID is set
;

INSERT examples​

Authorizes the request to assume a role in the project database

INSERT INTO supabase.database.jit_access (
role,
rhost,
ref
)
SELECT
'{{ role }}' /* required */,
'{{ rhost }}' /* required */,
'{{ ref }}'
RETURNING
user_id,
user_role
;

UPDATE examples​

Modifies the roles that can be assumed and for how long

UPDATE supabase.database.jit_access
SET
user_id = '{{ user_id }}',
roles = '{{ roles }}'
WHERE
ref = '{{ ref }}' --required unless SUPABASE_PROJECT_ID is set
AND user_id = '{{ user_id }}' --required
AND roles = '{{ roles }}' --required
RETURNING
user_id,
user_roles;

DELETE examples​

Remove JIT mappings of a user, revoking all JIT database access

DELETE FROM supabase.database.jit_access
WHERE user_id = '{{ user_id }}' --required
AND ref = '{{ ref }}' --required unless SUPABASE_PROJECT_ID is set
;