Adding custom API keys with selectable Postgres role for backend components #46804
Unanswered
LeonardoDiCappuccino
asked this question in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
When using a secret key for backend components, we grant them all privileges of the
service_roleso in most cases they have access to parts of the db they do not need to have or actually shouldn't. In my understanding this violates the principle of least privilege even if security is properly enforced in the backend components.Suggestion
Adding the possibility in
Project Settings -> API Keysto add a 'Service Key' (legacy service_role API key is not meant) where you can select a Postgres role. Custom roles can be selected there so we can use other roles thenanon,authenticatedandservice_role(from the publishable/secret key) in a backend components. With the custom Postgres role we have fine control over what the backend components can access in the db.Current solution
For people interested, this is my current approach in detail:
.env.a.
Dashboard -> Settings -> JWT Signing Keys -> Create Standby Keyb. Select Import an existing key, paste the previously generated and create.
c. Three-dot menu -> Move to previously used (Supabase will use this key just to verify, not for signing).
If the JWT gets compromised, just revoke the signing key from step 4 and all JWTs signed with it will be invalid.
While this works, it doesn't feel "official" and is extra work to setup
Beta Was this translation helpful? Give feedback.
All reactions