教程中架构 api 的权限被拒绝

permission denied for schema api in tutorial

我正在尝试新事物,但我被教程卡住了。当我按照本教程的第 4 步操作时:

https://postgrest.org/en/v9.0/tutorials/tut0.html#step-4-create-database-for-api

SQL 运行没有错误。我可以看到 table+data.

但是,当我以新创建的用户 authenticator 登录并尝试 select * from api.todos; 时,我收到错误:

ERROR:  permission denied for schema api
LINE 1: select * from api.todos;

我在 Postgres.app 上的 Postgres 13+14 和 Debian 上的 Postgres 13.4 上试过了。同样的错误。

这里有什么帮助吗?

是的,这是有意的。 authenticator 没有任何特权,只能转换角色,如 https://postgrest.org/en/v9.0/auth.html#authentication-sequence 所述。

因此在通过 psql 连接到 authenticator 之后,您可以:

set local role web_anon;

那你应该可以select * from api.todos.