【发布时间】:2019-03-31 05:26:37
【问题描述】:
我使用 feathers-permissions 和 feathers-authentication-hooks 来构建一个 RBAC 系统,但仍然无法实现。我想要的是例如:
- 只允许用户查看/更新他们自己的帐户。
- 允许管理员查看/更新任何帐户。
before: {
all: [],
find: [authenticate('jwt'), checkPermissions({roles: ['admin']})],
get: [authenticate('jwt'), checkPermissions({roles: ['admin']}), hooks.restrictToOwner({ownerField: '_id'})],
create: [hashPassword()],
update: [hashPassword(), authenticate('jwt'), checkPermissions({roles: ['admin']}), hooks.restrictToOwner({ownerField: '_id'})],
patch: [hashPassword(), authenticate('jwt'), checkPermissions({roles: ['admin']}), hooks.restrictToOwner({ownerField: '_id'})],
remove: [authenticate('jwt'), checkPermissions({roles: ['admin']})]
},
这样管理员仍然无法查看/更新其他帐户。
有什么帮助吗?
【问题讨论】:
标签: authentication permissions hook rbac feathersjs