Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distributed Grant File #95

Open
MangoChris opened this issue Feb 6, 2021 · 1 comment
Open

Distributed Grant File #95

MangoChris opened this issue Feb 6, 2021 · 1 comment

Comments

@MangoChris
Copy link

I'm thinking of using accesscontrol in a microservice architecture where multiple microservices will want to share the same authentication rules.

So my question is what pattern is best to solve this problem?

  • wrap it in a rpc?
  • wrap it in a rest API?
  • fetch the grant file from remote location and load it in?
  • other....?
@mohammadrz003
Copy link

mohammadrz003 commented Jul 23, 2023

I would say you can store grant objects into a database and retrieve all the objects from the database. and once you fetched that from the database, pass that to the AccessControl constructor:

// grant list fetched from DB:
let grantList = [
    { role: 'admin', resource: 'video', action: 'create:any', attributes: '*, !views' },
    { role: 'admin', resource: 'video', action: 'read:any', attributes: '*' },
    { role: 'admin', resource: 'video', action: 'update:any', attributes: '*, !views' },
    { role: 'admin', resource: 'video', action: 'delete:any', attributes: '*' },

    { role: 'user', resource: 'video', action: 'create:own', attributes: '*, !rating, !views' },
    { role: 'user', resource: 'video', action: 'read:any', attributes: '*' },
    { role: 'user', resource: 'video', action: 'update:own', attributes: '*, !rating, !views' },
    { role: 'user', resource: 'video', action: 'delete:own', attributes: '*' }
];
const ac = new AccessControl(grantList);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants