node-restful icon indicating copy to clipboard operation
node-restful copied to clipboard

How to make different pre-processors for collection and resource (GET /resources & GET /resources/:id)

Open lunatik-210 opened this issue 9 years ago • 2 comments

Greetings, is it possible to differentiate between GET /resources & GET /resources/:id? The point is that I want the user with one role have access only to GET /resources/:id but not to GET /resources. And for admin allow all of them for example.

Another words I want to be able to set different role policies for GET /resources & GET /resources/:id.

Can you point out on possible solution?

lunatik-210 avatar Jun 07 '16 07:06 lunatik-210

You could use before middle wear to check the path and user and then either return next() or next(401) for unauthorised.

OmgImAlexis avatar Jan 29 '17 06:01 OmgImAlexis

Yeah, I think @OmgImAlexis presents the best solution right now.

I played around making this a bit easier. A good project if anyone wants to work on it.

baugarten avatar Feb 13 '17 19:02 baugarten