【问题标题】:permission denied for schema api in tutorial教程中架构 api 的权限被拒绝
【发布时间】:2021-12-07 14:19:36
【问题描述】:

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

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

SQL 只是运行没有错误。我可以看到表格+数据。

但是,当我以新创建的用户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 上进行了尝试。同样的错误。

这里有什么帮助吗?

【问题讨论】:

    标签: postgresql postgrest


    【解决方案1】:

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

    所以在通过psql连接authenticator之后,你可以这样做:

    set local role web_anon;
    

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

    【讨论】:

    • 啊,这不明显。我学到了一些新东西。谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-03-18
    • 2023-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-27
    • 2019-12-31
    • 1970-01-01
    相关资源
    最近更新 更多