Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Exposing JWT Token expiration #448

Open
superandrew opened this issue Jul 2, 2018 · 2 comments
Open

Exposing JWT Token expiration #448

superandrew opened this issue Jul 2, 2018 · 2 comments

Comments

@superandrew
Copy link

superandrew commented Jul 2, 2018

I searched the documentation for a setting that allows to expose the token expiration. I implemented a response handler, but i don't know where to take the expiration date.

Something like:

def jwt_response_payload_handler(token, user=None, request=None):
    return {
        'token': token,
        'expiration':"12312312312312"
    }

Thanks

@superandrew
Copy link
Author

superandrew commented Jul 2, 2018

alright so this is my implementation:
import datetime
from rest_framework_jwt.settings import api_settings

def jwt_response_payload_handler(token, user=None, request=None):

    return {
        'token': token,
        'exp': datetime.datetime.utcnow() + api_settings.JWT_EXPIRATION_DELTA
    }

where is that date checked? I checked the db but found no tables where this information is stored. Sorry but I'm not finding this on the docs.

@cyberbudy
Copy link

Actually, it's a part of a token. You can check jwt_decode_handler method where token is decoded by jwt library. Also that library performs multiple checks, such as checking expiry time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants