-
Notifications
You must be signed in to change notification settings - Fork 120
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
How to get token from unprotected route #178
Comments
You can initialize koajwt with the option |
Actually now that I think about it, this won't work. Why do you want to do this? You could do this by using the jsonwebtoken library's jwt.decode function directly for the unprotected routes. See https://www.npmjs.com/package/jsonwebtoken#jwtdecodetoken--options |
I have an entity that can be publicly visible but depending on the record property ( So for example, let's say I'm rebuilding github and I want to fetch a specific repository. I want that endpoint to be public because the system allows for public repos that don't require authorization. But if the resource the user is trying to fetch is private then I need to reject the request. Does that make sense? Yeah that was my thinking as well: rebuild the parts of koa-jwt that extract the authorization header and manually add a ctx.state.user object for those unprotected routes. |
Hey all, I have routes that are unprotected but I still want to grab the user information if they provide an
Authorization
token, how could this be accomplished using this library? It seems like I either have to protect the routes to get thectx.state.user
object or leave them unprotected and not have access to the state user object.Thanks!
The text was updated successfully, but these errors were encountered: