In my DDD application written in javascript (Node.js), I am stumbling on the implementation of the authorization generic subdomain. I checked on the RBAC / ACL authorization models on how to implement this, but they don't seem to have per-instance permissions, which I need.
From what I understand, RBAC has role-based authorizations. Users are assigned to roles. Roles are hierarchical and inherit permissions. Roles can have multiple permissions. Permissions allow commands to be executed on resources.
But, as defined by RBAC, resources are generic like "Posts", "Comment", "Book", etc. They are not instance-specific (like Post(id:9283984)). For example, it's not possible to define in RBAC that only a user that created a Post can edit it. It seems to be impossible to assign the role "Admin" to a "User(id:(8290321)" on a given "Post(id:2398493)"
It becomes even more complicated to define roles that have permissions to execute commands that modify other people's roles on a specific a resource.
The requirements of my applications are :
The User who issued the CreateLedger command is automatically assigned as the Admin of this Ledger. He can only assign other people as Managers or Collaborators or Viewers of the Ledgers he is Admin of. He can also revoke those roles. Managers are allowed to manage the Accounts of the Ledger. Collaborators are allowed to edit Transactions on this Ledger, and Viewers only able to view the data (read only). An Admin can assign the Admin role to books he is Admin of to another User.
My initial idea was that in order for a user to be able to manage user's roles on a resource, there would need to be a mapping between
user(id:X) -> role(name:Z) -> permissions -> resource(id:Y) -> commands
but in RBAC it's only possible to assign
user(id:X) -> role(name:Z) -> permissions -> resource(name:"Ledger") -> commands
Then, to overcome this limitation of RBAC, I thought about naming resources with their ids like
user(id:X) -> role(name:Z) -> permissions -> resource(name:"Ledger:39823847") -> commands
But this seems wrong. I haven't seen any example of RBAC using resource names as mapping for actual instances.
I am using the wrong hammer? I am seeing this wrong? Is there some other access control model more suited to this task? Or is this the way to go? I would appreciate if someone would point me in the right direction.
Thank you for your help