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

Refresh token was not included in request data. #261

Open
hsb-tonmoy opened this issue May 17, 2021 · 3 comments
Open

Refresh token was not included in request data. #261

hsb-tonmoy opened this issue May 17, 2021 · 3 comments

Comments

@hsb-tonmoy
Copy link

By default, if you're using JWT and Token Blacklist, the Logout view tries to find the Refresh token in the request body. However, if I am using HttpOnly cookie, my Refresh token wouldn't be in the request body.

It can be fixed by changing:

if 'rest_framework_simplejwt.token_blacklist' in settings.INSTALLED_APPS:
                # add refresh token to blacklist
                try:
                    token = RefreshToken(request.get['refresh'])

to

if 'rest_framework_simplejwt.token_blacklist' in settings.INSTALLED_APPS:
                # add refresh token to blacklist
                try:
                    token = RefreshToken(request.COOKIES['refresh_token'])

But it is quite cumbersome to define my own view for one line of change. Please consider making this change to the codebase.

@Luctia
Copy link

Luctia commented Aug 6, 2021

Slightly related: #191 you can find some middleware via the code mentioned there that will do that. I agree that it should be added, though.

@emripka
Copy link

emripka commented May 12, 2022

You should further be using the JWT_AUTH_REFRESH_COOKIE setting to decide which cookie to grab:

if 'rest_framework_simplejwt.token_blacklist' in settings.INSTALLED_APPS:
      # add refresh token to blacklist
      try:
          refresh_cookie = getattr(settings, 'JWT_AUTH_REFRESH_COOKIE', 'refresh_token')
          token = RefreshToken(request.COOKIES[refresh_cookie])

@Nooruzbai
Copy link

Could you please write where I should put this code?pleaaaas=)

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

4 participants