Wolkenkit: ACLs for authorization and user roles

心已入冬 提交于 2019-12-11 00:15:44

问题


I am trying to understand on how to extend the wolkenkit auth layer.

Say i want users with different roles: normal, moderator and admin.

  • normal users can see and modify their own content, but aren't allowed to modify content from other users.

  • moderator users are allowed to modify all entries, but don't have permission to delete anything than their own content.

  • admin users can modify and delete everything.

  • There are also unauthenticated guest users who can read everything but modify nothing.

Reading the docs for Write model: Configuring authorization i can model the guest/normal use case by writing something along the lines of:

const initialState = {
  isAuthorized: {
    commands: {
      issue: { forAuthenticated: false, forPublic: false }
    },
    events: {
      issued: { forAuthenticated: true, forPublic: true }
    }
  }
};

For my requirements i would need additional roles defined in this object. Something like { forModerator: true, forAdmin: true }.

There is also Granting access from a command to change permissions at runtime, but i am not sure if that would work. Even if it does, that feels quite hacky.

Is this somehow possible?


回答1:


Disclaimer: I am one of the developers of wolkenkit.

To cut a long story short: No, right now unfortunately this is not possible, but this feature is on our roadmap. At least today, I can't tell you when this will be available.

Your best option would be to do it on your own. One way to do this might be to use your identity provider to include a moderator claim in the JWTs of the moderators, and then handle this in the command handler appropriately.

In the command handler you have access to the token by

command.user.token

so you can get the claims as needed. I'm very sorry, that there is no better answer right now :-(



来源:https://stackoverflow.com/questions/45976860/wolkenkit-acls-for-authorization-and-user-roles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!