首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PostgreSQL / PostGraphile行权限无法工作

PostgreSQL / PostGraphile行权限无法工作
EN

Stack Overflow用户
提问于 2018-07-08 21:20:16
回答 1查看 693关注 0票数 1

我正在尝试使用GraphQL (以前称为PostGraphQL)来设置一个PostGraphile服务器,但不能使行权限正常工作,这意味着我一直得到被拒绝权限的消息,尽管它应该能工作。下面是我的模式:

代码语言:javascript
复制
create function app.current_user() returns app.profile as $$
  select *
  from app.profile
  where id = current_setting('jwt.claims.person_id')::integer
$$ language sql stable;

comment on function app.current_user() is 'Gets the person who was identified by our JWT.';

grant select (name,about,created_at,updated_at) on table app.profile to app_user;
grant update (name,about) on table app.profile to app_user;
alter table app.profile enable row level security;


create policy select_profile on app.profile for select to app_user
  using (id = current_setting('jwt.claims.person_id')::integer);

create policy update_profile on app.profile for update to app_user
  using (id = current_setting('jwt.claims.person_id')::integer);

就我在调试输出中所能看到的情况而言,一切都正常工作。我可以对JWT令牌进行身份验证,得到一个JWT令牌,当JWT令牌无效时,它会发出一个正确的错误消息,所以没有任何错误消息。

我做错了什么,或者如何更密切地调试正在发生的事情?

我用的是PostGraphile v4和PostgreSQL 10.4

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-09 12:54:51

我自己发现了问题。事实证明,即使您没有选择id,但只在WHERE部分使用它,也必须对id授予权限。

因此,在上面的示例中,将其修改为:

将表app.profile上的选择(id、name、about、created_at、updated_at)授予app_user;

那就应该管用了。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51236075

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档