1

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.

Not Gabriel
  • 531
  • 4
  • 13
  • This might be of help: http://stackoverflow.com/questions/20340268/get-request-object-in-passport-strategy-callback – Tholle Jun 30 '15 at 13:40
  • 1
    @Tholle Geez, it was right away in the documentation... and I did read it, can't believe I let it pass. Anyway, thanks a lot. – Not Gabriel Jun 30 '15 at 13:52

0 Answers0