OptimalBits / node_acl

Access control lists for node applications
2.62k stars 369 forks source link

Not MVC resources ? #249

Open ghost opened 6 years ago

ghost commented 6 years ago

Hi, Is it possible to use this module with resources wich are not MVC ? I want to protect instance objects rather than routes.

I want to do something like this into my controller (i'm using routing-controllers):

@Get("/myaction/candidat_id/:candidat_id")
    test((@Param("candidat_id") candidat_id: number, @Req() request: Request, @Res() response: Response)   
    { 
        ...
 if (acl.isAllowed(myUserId, myArticleId, 'show') {
// display article
}    
}
ghost commented 6 years ago

Can anyone help me please?

ghost commented 6 years ago

No idea about this question?

john-osullivan commented 6 years ago

Your question is kind of unclear, as Model View Controller doesn't really apply in this ACL context. I'm not using the middleware, so no ideas on how it would work there, but you can just make one resource for every article.

It looks like the pattern for max granularity is to:

Not sure how it scales, but that provides the most granularity across the application. Note that I'm not a contributor to this library, just a developer in the process of implementing the pattern as described. Would love to hear from @manast about any issues he'd foresee as this pattern scales!