Is there a way to get the route name and http method inside Passport's authentication strategy callback?

时间:2015-06-30 13:38:14

标签: javascript node.js acl passport.js

I'm not sure the title is very clear, but here's what I'm aiming to do:

I'm using passport with a BasicStrategy. Then I'm calling the authentication method like this:

router.route('/users').get(passport.authenticate('basic', {session: false}), function(req, res) { ... });

I want to know if inside my BasicStrategy implementation I can get which route is being called and under which HTTP Method.

I need to do this because I need to implement permissions for the routes. I have in my database a table with roles and one table with permissions. Inside the permissions table, I have one boolean column for each CRUD (permission_post,get,put,delete) operation, the role id and the route name.

That's why I need to know the route name and the HTTP Method, so I can use the user's role id and fetch if the user is or is not allowed to access the route.

0 个答案:

没有答案