Skip to content
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

doesn't play well with other "Authorization"-header auth plugins #57

Open
radix opened this issue Jun 5, 2020 · 2 comments
Open

doesn't play well with other "Authorization"-header auth plugins #57

radix opened this issue Jun 5, 2020 · 2 comments

Comments

@radix
Copy link

radix commented Jun 5, 2020

When the Authorization header is sent with a prefix other than the configured one (default Bearer, though I override it to be JWT in my app), drf-jwt raises an AuthenticationFailed. This means that authentication is completely stopped and other auth plugins don't get a chance to run.

My app uses both drf-jwt and DRF Token authentication, so when I switched from the old djangorestframework-jwt to this, my DRF Token authentication stopped working. The old djangorestframework-jwt properly returned None instead of raising AuthenticationFailed when the prefix wasn't one it expected.

@radix
Copy link
Author

radix commented Jun 5, 2020

To work around this I subclass JSONWebTokenAuthentication and override authenticate to do this:

    def authenticate(self, request):
        if request.environ.get('HTTP_AUTHORIZATION', '').startswith('JWT'): # Note I override prefix from Bearer to JWT
            return super().authenticate(request)

@igorpejic
Copy link

I am experiencing the same when trying to use an email confirmation link to create an account.

One would expect the Authentication to fall-through, and try other authentication methods, the same as it did in the original repository.

Or am I missing something?

awais786 added a commit to awais786/django-rest-framework-jwt that referenced this issue Jul 18, 2020
Styria-Digital#63

When the Authorization header is sent with a prefix
other JWT it trigger error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants