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

Recommended way for resource-based access control #57

Open
jsardev opened this issue Oct 2, 2018 · 8 comments
Open

Recommended way for resource-based access control #57

jsardev opened this issue Oct 2, 2018 · 8 comments
Labels
feature request Considered to be implemented.

Comments

@jsardev
Copy link

jsardev commented Oct 2, 2018

So I'd like to restrict access to specific resource instances. I came with an idea to just use .resource('video:id') for grants but I'm not sure if it's a good way.

To be more specific: I'm talking about a case where user X owns a resource, and user Y needs to have access to it, without having a read:any grant.

Do you recommend any other way to handle this problem?

@scandinave
Copy link

Hi,
You should not use the id as identifier of the resource. You should instead use the own possession like this :
ac.grant("role").createOwn("video").

It's up to you how you implement the own concept in your application. If you want a example, i have created a middleware for express that check the own possession using a resource array inside the user connection token.

In my application, i have a datatable resource that hold the link between a role and a resource. When the user connect to the app, the resource array is put inside the generated token.

@jsardev
Copy link
Author

jsardev commented Oct 5, 2018

@scandinave Thanks for your reply! Unfortunately, I'm not talking about resources owned by a given user. I mean resources created by user X which should be accessible by user Y, without read:any.

@jsardev
Copy link
Author

jsardev commented Oct 6, 2018

@scandinave Oh, I guess I misunderstood your reply. Having a resources property in the user's token/session makes sense 😄 Thanks for the suggestion!

@scandinave
Copy link

scandinave commented Oct 6, 2018

Don't forget to sign your token to avoid any modification.

The other solution if you want user delegating access to another user is to use opened id connect/oauth2.
Mayby something like keycloak is what you want.

@jsardev
Copy link
Author

jsardev commented Oct 6, 2018

@scandinave Sure thing. One more question: I need also to distinguish the access to the subtype of the resource, i.e. media:video or media:attachment. I am more clearly coming to a conclusion that I could just need ABAC instead of RBAC, am I right?

@scandinave
Copy link

AccessControl supported providing attributes like this :

ac.grant("role").createOwn("media", ["video, attachment"])

You can then filter wat can be return to user with the filter method

In my projects, i use this method in my express route before returning the json object to purge unwanted value.

@jsardev
Copy link
Author

jsardev commented Oct 6, 2018

IMO naming it attributes is very confusing. The only thing it does is filtering properties of the given resource. Dunno why it's called attributes.

I'm talking about different situation. Consider a resource like this:

{
    "name": "some name",
    "type": "video" // this can be also be an "attachment"
}

Now, using accesscontrol, the only way to handle different grants based on the type is to call the resource media:video and media:attachment - which kinda leads me to a thought that this system is not what I'm looking for.

@scandinave
Copy link

Yeah,
Author tell us that v 3.0 was in preparation but it seams to be a little busy at this time

@onury onury added the feature request Considered to be implemented. label Feb 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Considered to be implemented.
Projects
None yet
Development

No branches or pull requests

3 participants