Skip to content

Best way to allow backend access for certain functions? #3387

Discussion options

You must be logged in to vote

In a frontend scenario, I am running ownership checks based on auth.uid() however in the backend case, I don't imagine there is a user "signed in" the same way when using the service key?

If you check the service key contents, it has a role claim which is mapped to a service_role postgres role(you can check this with auth.role()). So yes, it should be similar with the difference that an auth.uid() is not present because service_role is not a web user(not mapped to a row in auth.users).

My first impression is that it could be as simple as only allowing EXECUTE to a specific user, but not sure:

Yes, that would work, you could create another role and do GRANT EXECUTE on your functions on…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by steve-chavez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants