Disable jwt_required for OPTIONS requests
See original GitHub issueI notice that if a try to protect an entire blueprint with @jwt_required, than also the OPTIONS method is protected.
OPTIONS method should not include crendetials, see here.
The @jwt_required decorator should ignore OPTIONS like in flask_login:
@wraps(func)
def decorated_view(*args, **kwargs):
if request.method in EXEMPT_METHODS:
return func(*args, **kwargs)
elif current_app.login_manager._login_disabled:
return func(*args, **kwargs)
elif not current_user.is_authenticated:
return current_app.login_manager.unauthorized()
return func(*args, **kwargs)
return decorated_view
where EXEMPT_METHODS=set(["OPTIONS"])!
I could fix this and create a pull request if this is not a desired choice!
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Disable Spring Security for OPTIONS Http Method
I am writing a JS client for it and using JQuery to send the GET/POST requests. The application is CORS enabled with this...
Read more >Configuration Options — flask-jwt-extended 4.4.4 documentation
Cross Site Request Forgery Options: ... The string or list of audiences ( aud ) expected in a JWT when decoding it. Default:...
Read more >Disable authentication for HTTP OPTIONS method (preflight ...
The only way out seems to be to configure the server to not enforce authentication for HTTP OPTIONS requests. Is there any way...
Read more >Add an option to disable logging for a specific request
Currently every request created by the rest client code editor is saved to the log. When I need to generate JWT token based...
Read more >Techniques for bypassing CORS Preflight Requests to ...
If the target server accepts the OPTIONS request and notifies the web ... origin may require two roundtrips: one for the OPTIONS request, ......
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

@mgd722 to be honest, I don’t remember why I wrote it… I think I meant that it’s not very clean and maybe it should be more pythonic to explicit it by decorating every route that needs to be protected… What I don’t like too much is to have a “do nothing function” and decorate it…
Anyway, I like that practice and I’ll continue to use it!!
Perfect, thanks for all of the information. It sounds like excluding
OPTIONSfrom the jwt_required functions would be the correct thing to do. If you want to submit a pull request I would be happy to get that merged, or I could work on getting that fixed up sometime next week.Cheers 👍