2

I have a Postgres database where we have multiple tables and views. I have done Postgrest setup to expose it to the application. Along with the Postgrest API, I also have swagger which is working fine.

Now in postgrest API, we have PGRST_DB_ANON_ROLE required env variable which basically works for anonymous user. Now swagger UI only shows tables and views where the anonymous user has select permission on the tables/views.

I have also implemented token-based authentication. I want data to be secured and read should also be restricted from anonymous user.

Case 1 - I have given schema usage permission to the anonymous user. (no select permission on tables/views) Result - Swagger UI does not show endpoints for tables/views

Case 2 - I have given schema usage permission to the anonymous user and also select permission on tables/views. Result - Swagger Ui shows endpoints but now read endpoints works without any authentication(token).

I want to show the tables/views endpoint in swagger but read endpoint should also be accessed with an authentication token.

Ashok Rayal
  • 405
  • 3
  • 16
  • 1
    This is a pending issue in postgrest: https://github.com/PostgREST/postgrest/issues/1449. The workaround is to add a hardcoded token for only the root endpoint with a reverse proxy(like Nginx). – Steve Chavez Feb 02 '21 at 03:43
  • Thank you @SteveChavez, I have gone through this git issue. Can you please explain how to set up the hardcoded token in detail. – Ashok Rayal Feb 04 '21 at 14:27

0 Answers0