Skip to content

Disable jwt_required for OPTIONS requests #119

@ludusrusso

Description

@ludusrusso

I 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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions