-
Notifications
You must be signed in to change notification settings - Fork 126
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
Q: How do I set jwt auth to all routes? #149
Comments
Ah I just saw it's enabled by default for all routes. Maybe you can state this in your docs. |
@abeninskibede thanks for getting in touch! My sincere apologies that the docs are unclear leading to any confusion. :-( |
Will do thanks. |
How do I set JWT Auth to All Routes?@abeninskibede asked how to set all routes to use JWT Auth in hapi-auth-jwt2/issues/149 We tend to enable // setting the 3rd argument to true means 'mode' is 'required' see: http://hapijs.com/tutorials/auth#mode
server.auth.strategy('jwt', 'jwt', true, { // so JWT auth is required for all routes
key: process.env.JWT_SECRET,
validateFunc: require('./jwt2_validate_func'),
verifyOptions: { ignoreExpiration: true, algorithms: [ 'HS256' ] }
});
When you want a particular route to _not require_ JWT auth you simply set server.route({
method: 'GET',
path: '/login',
handler: login_handler, // display login/registration form/page
config: { auth: false } // don't require people to be logged in to see the login page! (duh!)
}); The best place to understand everything about Hapi Auth is in the docs: http://hapijs.com/tutorials/auth#setting-a-default-strategy See README 👍 |
Hey guys,
I like your plugin but was wondering if there is a way to apply jwt-auth2 as default auth for all routes?
I see that you can specify
config: {auth: 'jwt'}
to a specific route but how do I enable this by default for all my routes?The text was updated successfully, but these errors were encountered: