Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom 401 handler #36

Open
pronebird opened this issue Jul 14, 2015 · 7 comments
Open

Custom 401 handler #36

pronebird opened this issue Jul 14, 2015 · 7 comments

Comments

@pronebird
Copy link

Looking at current code base I don't see any way to plug-in a custom error handler when invalid bearer token provided. Would be great to have a way to customize the response, e.g. in my case I output JSON with error description..

@todbot
Copy link

todbot commented Jan 13, 2016

+1

@Kadrian
Copy link

Kadrian commented Jun 11, 2016

I agree, what would need to be done to make 401 possible?

@aburkut
Copy link

aburkut commented Sep 21, 2016

+1

@peteruithoven
Copy link

I'm having the same issue. I opened: http://stackoverflow.com/questions/37330642/passport-local-mongoose-how-to-get-authentication-error-message

You could provide a callback to Passport's authenticate middleware, but then you'd have to parse the challenge string to get the useful information.

@jcyh0120
Copy link

+1, is there any workaround for this?

@mk-pmb
Copy link

mk-pmb commented Jan 24, 2017

@jcyh0120,

is there any workaround for this?

You can always intercept the middleware with another one that gives it a proxy (fake) response object and "next" function, and modify its response. npm probably has some modules for this purpose but I don't know any from head.

@rgilling
Copy link

rgilling commented Feb 4, 2017

+1 would be great if there was an option to resolve with an empty token instead of responding with 401 to the client. I had an issue where I wanted to support guest (no token) and registered requests. I got around it by adding an extra middleware that adds a dummy authorization header for guest accounts, but the better solution would be to allow the developer to handle the empty token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants