Route authentication and protection #3201
-
Protection of all routes in an existing database (postgresql v16), authentication for routes with access levels. Is there any working example? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As a summary: Routes are protected by the permissions given to the database user who is making the request. The user could be anonymous (set by
Suppose you have an existing database:
And you set postgrest config like this: db-uri = "postgres://postgres:password@localhost:5432/mydatabase"
db-schemas = "public"
db-anon-role = "generic_user" Then only the relations inside the Maybe a more detailed example could be added to the docs for an existing database (commented in PostgREST/postgrest-docs#748 (comment)) With that in mind, check the docs for more complete info related to security: |
Beta Was this translation helpful? Give feedback.
As a summary:
Routes are protected by the permissions given to the database user who is making the request. The user could be anonymous (set by
db-anon-role
) or an authenticated one through JWT. Only the schemas specified indb-schemas
are exposed.Suppose you have an existing database:
And you set postgrest config like this:
Then only the relations inside the
public
schema will be exposed, and only those that can be accessed bygeneric_user
(the anonymous role)…