Invalid JWT errors not thrown for decorated optional routes
See original GitHub issueI’m migrating from flask-jwt and make extensive use of decorated required and optional routes. My tests also have extensive coverage for invalid JWT cases. I’ve confirmed that invalid JWTs are handled correctly for jwt_required() routes, but not fully for jwt_required(optional=True) routes. Note that I use “JWT” as my prefix instead of “Bearer”. I’ve also seen that flask-jwt-extended test cases do not cover these types of cases for optional routes.
Specifically these routes are allowed access for these invalid tokens. It is obviously important that any type of error for a submitted token (in any location) is rejected even when it is optional.
- "JWT "
- “JWT xxxx”
- “JWT xxxx xxxx”
- “JXX”
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
"Not enough segments" when seding a GET message with ...
Any route decorated with this will require a valid JWT to be present in the request (unless optional=True, in which case no JWT...
Read more >Using authentication decorators in Flask - CircleCI
In this case, an error is provided if the input to the decorator is incorrect, or if it is missing required inputs.
Read more >JWT (JSON Web Tokens) Errors | Invalid JWT Signature
This post reviews JWT errors and specifically how to resolve the invalid_grant:Invalid JWT Signature error. For Invalid JWT Signature, check if ...
Read more >JWT authentication in Rust - LogRocket Blog
Upon logging in, a session token is mapped onto a JWT, which is then ... #[error("jwt token not valid")] JWTTokenError, #[error("jwt token ...
Read more >Authentication | NestJS - A progressive Node.js framework
A "verify callback", which is where you tell Passport how to interact with your user store (where you manage user accounts). Here, you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I opted to tread
Authorization: Beareras an error like you originally suggested, as well as fixed up the other error cases we discussed.I also added a
JWT_QUERY_STRING_VALUE_PREFIXoption that should allow you to support query strings the way you want to.Both of these have been released in v4.2.0!
Currently no, it only supports
<key>=<token>, but I have no problem adding a configuration option that would make something like<key>=<type> <token>work. There are a couple other PRs in the pipeline already, so I could probably add it sometime this weekend and get a new release cut.I can see the argument for that. Let me consider it and I’ll figure out exactly what I want to do while working on the other enhancements this weekend.
Cheers 👍