python - JWT integration with django -
i new django (not drf) , have hard time configuring authentication requirements. have external authentication service gets username , password , returns jwt. after have jwt how should save token , provide every request browser. , after can validate it?
thanks!
for every call service there should header call
{'authorization':'token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'}
and can use in views.py :
if request.user.is_authenticated():
it has included in settings file of django project.
jwt_auth = { # 'jwt_encode_handler': # 'rest_framework_jwt.utils.jwt_encode_handler', # 'jwt_decode_handler': # 'rest_framework_jwt.utils.jwt_decode_handler', # 'jwt_payload_handler': # 'rest_framework_jwt.utils.jwt_payload_handler', # 'jwt_payload_get_user_id_handler': # 'rest_framework_jwt.utils.jwt_get_user_id_from_payload_handler', # 'jwt_response_payload_handler': # 'rest_framework_jwt.utils.jwt_response_payload_handler', # 'jwt_secret_key': settings.secret_key, # 'jwt_algorithm': 'hs256', # 'jwt_verify': true, # 'jwt_verify_expiration': false, # 'jwt_leeway': 0, 'jwt_expiration_delta': datetime.timedelta(days=1), # 'jwt_audience': none, # 'jwt_issuer': none, # 'jwt_allow_refresh': false, # 'jwt_refresh_expiration_delta': datetime.timedelta(days=7), # 'jwt_auth_header_prefix': 'jwt', }
read more here.
Comments
Post a Comment