parent
b1fd168302
commit
302622b675
7 changed files with 73 additions and 9 deletions
@ -0,0 +1,25 @@ |
|||||||
|
from datetime import datetime |
||||||
|
from calendar import timegm |
||||||
|
from rest_framework_jwt.settings import api_settings |
||||||
|
|
||||||
|
|
||||||
|
def custom_jwt_payload_handler(user): |
||||||
|
|
||||||
|
payload = { |
||||||
|
'exp': datetime.utcnow() + api_settings.JWT_EXPIRATION_DELTA, |
||||||
|
'out_key': str(user.out_key), |
||||||
|
'email': user.email, |
||||||
|
} |
||||||
|
|
||||||
|
if api_settings.JWT_ALLOW_REFRESH: |
||||||
|
payload['orig_iat'] = timegm( |
||||||
|
datetime.utcnow().utctimetuple() |
||||||
|
) |
||||||
|
|
||||||
|
if api_settings.JWT_AUDIENCE is not None: |
||||||
|
payload['aud'] = api_settings.JWT_AUDIENCE |
||||||
|
|
||||||
|
if api_settings.JWT_ISSUER is not None: |
||||||
|
payload['iss'] = api_settings.JWT_ISSUER |
||||||
|
|
||||||
|
return payload |
||||||
Loading…
Reference in new issue