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

With USE_JWT and blacklist app, logout fail with JWT_HTTP_ONLY #541

Open
mbegoc opened this issue Aug 31, 2023 · 4 comments
Open

With USE_JWT and blacklist app, logout fail with JWT_HTTP_ONLY #541

mbegoc opened this issue Aug 31, 2023 · 4 comments

Comments

@mbegoc
Copy link

mbegoc commented Aug 31, 2023

On line https://github.com/iMerica/dj-rest-auth/blob/master/dj_rest_auth/views.py#L181 the code look for the refresh token into the data, but with HTTP_ONLY, the token can be found only in cookies.

Is it by design (no need to blacklist the refresh cookie in this case) or should the code look into both data and cookies?

@Routhinator
Copy link

Routhinator commented Nov 18, 2023

EDIT - Realized when I looked at this I missed that this was this library's source 🤦

That's the idea behind HttpOnly cookies, the app doesn't handle them, the server and the browser do - and they are sent on each request to the server automatically.

In the Django request object, there is a COOKIES property - the code needs to look there if JWT_HTTP_ONLY is on:

request.COOKIES['token']

A simple edit to the APIView to have an if condition there should do the trick, I'll test that.

@Routhinator
Copy link

I've opened a PR to address this one @iMerica

iMerica pushed a commit that referenced this issue Nov 26, 2023
* #541 Check for refresh cookie when JWT_AUTH_HTTPONLY is True

* #541 Address test failures.
@Routhinator
Copy link

Fix has merged to master, pending release.

@Aniket-Singla
Copy link
Contributor

Can this be closed? I see its released.

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

3 participants