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 Issue #25

Open
wuuuduu opened this issue Dec 21, 2019 · 1 comment · May be fixed by #102
Open

Refresh Token Issue #25

wuuuduu opened this issue Dec 21, 2019 · 1 comment · May be fixed by #102

Comments

@wuuuduu
Copy link

wuuuduu commented Dec 21, 2019

RefreshAuthTokenSerializer has bug in validate method.
In situation if token is expired, but still could be refreshed it returns an error saying "Token is expired", but is should not raise this error.

As I see, we are calling payload = _check_payload(token=token) which is responsible for raising this error.

One of many ways to fix it:

file loc: rest_framework_jwt.serializers._check_payload
def _check_payload(token):
      try:
          payload = JSONWebTokenAuthentication.jwt_decode_token(token)

=>

def _check_payload(token, *args, **kwargs):
      try:
          payload = JSONWebTokenAuthentication.jwt_decode_token(token, *args, **kwargs)

file loc:  rest_framework_jwt.serializers.RefreshAuthTokenSerializer.validate
payload = _check_payload(token=token)

=>

payload = _check_payload(token=token, check_jwt_verify_expiration=False)

file loc: rest_framework_jwt.utils.jwt_decode_token
def jwt_decode_token(token):
  options = {
        'verify_exp': api_settings.JWT_VERIFY_EXPIRATION,
     }

=>

def jwt_decode_token(token, check_jwt_verify_expiration=True):
  options = {
        'verify_exp': api_settings.JWT_VERIFY_EXPIRATION and check_jwt_verify_expiration,
     }
@wuuuduu
Copy link
Author

wuuuduu commented Dec 21, 2019

and I think we should introduce new setting which will tell if app should rotate refresh token.

For now, we are not rotating token, because: new_payload['orig_iat'] = orig_iat <- which won't change life time of refresh token
we could do something like this:
file: rest_framework_jwt.serializers.RefreshAuthTokenSerializer.validate

if api_settings.ROTATE_REFRESH_TOKEN **is False**:
   `new_payload['orig_iat'] = orig_iat`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant