Sunday 21 May 2017

Passport - 'Authentication Required' Dialog in Browser

I'm protecting an API in my web app using passport. Before hitting the resource, I want the user to login/authorize first.

Have tried both LocalStrategy and BasicStrategy - their implementation are almost 100% the same, just look for a user by email and verify password. If I use BasicStrategy, the browser will bring up a dailog saying 'Authentication Required' and ask for username & password. However if I use LocalStrategy, it just says 'Unauthorized', and no chance to login.

So my questions are:

  1. How does browser decide to bring up the login dialog, or is it done by BasicStrategy?

  2. Is it possible to show a login page with some UI, instead of the simple dialog?

Note that it's part of OAuth process so I don't really want to redirect to the login page.



via Stanley Luo

No comments:

Post a Comment