Format: application/x-python-code
⬇ Download File (5.7 KB)
   1  o
   2  
   3  G'h��@s\dZddlmZddlmZddlmZddlmZddl	m
   4  Z
   5  dedefd	d
   6  �Zdedede
   7  fd
   8  d�Zdefdd�Zdedefdd�Zdededefdd�Zdedefdd�Zdedefdd�Zdededefdd�Zdededefdd �Zd!ededefd"d#�Zd!ed$ede
   9  fd%d&�Zd!ed$edefd'd(�Zdededefd)d*�Zd+edefd,d-�Zd.S)/a�
  10  These are the default methods implementations that are used in this extension.
  11  All of these can be updated on an app by app basis using the JWTManager
  12  loader decorators. For further information, check out the following links:
  13  
  14  http://flask-jwt-extended.readthedocs.io/en/latest/changing_default_behavior.html
  15  http://flask-jwt-extended.readthedocs.io/en/latest/tokens_from_complex_object.html
  16  �)�
  17  HTTPStatus)�Any)�jsonify)�ResponseReturnValue)�config�userdata�returncC�iS)z�
  18      By default, we add no additional claims to the access tokens.
  19  
  20      :param userdata: data passed in as the ```identity``` argument to the
  21                       ```create_access_token``` and ```create_refresh_token```
  22                       functions
  23      ��rr
  24  r
  25  �ZC:\Users\shubh\Videos\agent\nova\Lib\site-packages\flask_jwt_extended/default_callbacks.py�"default_additional_claims_callback�r
  26  �jwt_headers�jwt_datacC�dS)NFr
  27  )rrr
  28  r
  29  r�default_blocklist_callbacksrcCr	)aG
  30      By default header typically consists of two parts: the type of the token,
  31      which is JWT, and the signing algorithm being used, such as HMAC SHA256
  32      or RSA. But we don't set the default header here we set it as empty which
  33      further by default set while encoding the token
  34      :return: default we set None here
  35      r
  36  )�default_headersr
  37  r
  38  r�default_jwt_headers_callback!rrcCs|S)a)
  39      By default, we use the passed in object directly as the jwt identity.
  40      See this for additional info:
  41  
  42      :param userdata: data passed in as the ```identity``` argument to the
  43                       ```create_access_token``` and ```create_refresh_token```
  44                       functions
  45      r
  46  rr
  47  r
  48  r�default_user_identity_callback,s	r�_expired_jwt_header�_expired_jwt_datacC�ttjdi�tjfS)z�
  49      By default, if an expired token attempts to access a protected endpoint,
  50      we return a generic error message with a 401 status
  51      zToken has expired�rr�
  52  error_msg_keyr�UNAUTHORIZED)rrr
  53  r
  54  r�default_expired_token_callback8�r�error_stringcC�ttj|i�tjfS)z�
  55      By default, if an invalid token attempts to access a protected endpoint, we
  56      return the error string for why it is not valid with a 422 status code
  57  
  58      :param error_string: String indicating why the token is invalid
  59      )rrrr�UNPROCESSABLE_ENTITY�rr
  60  r
  61  r�default_invalid_token_callbackB��r"cCr)z�
  62      By default, if a protected endpoint is accessed without a JWT, we return
  63      the error string indicating why this is unauthorized, with a 401 status code
  64  
  65      :param error_string: String indicating why this request is unauthorized
  66      rr!r
  67  r
  68  r�default_unauthorized_callbackOrr$�
  69  jwt_headercCr)z�
  70      By default, if a non-fresh jwt is used to access a ```fresh_jwt_required```
  71      endpoint, we return a general error message with a 401 status code
  72      zFresh token requiredr�r%rr
  73  r
  74  r�"default_needs_fresh_token_callbackYr#r'cCr)z�
  75      By default, if a revoked token is used to access a protected endpoint, we
  76      return a general error message with a 401 status code
  77      zToken has been revokedrr&r
  78  r
  79  r�default_revoked_token_callbackfr#r(�_jwt_headercCs(|tj}tjd|��i}t|�tjfS)z�
  80      By default, if a user_lookup callback is defined and the callback
  81      function returns None, we return a general error message with a 401
  82      status code
  83      zError loading the user )rZidentity_claim_keyrrrr)r)r�identity�resultr
  84  r
  85  r�"default_user_lookup_error_callbackss
  86  r,�	_jwt_datacCr)zG
  87      By default, we do not do any verification of the user claims.
  88      Tr
  89  �r)r-r
  90  r
  91  r�#default_token_verification_callback�sr/cCr)zz
  92      By default, if the user claims verification failed, we return a generic
  93      error message with a 400 status code
  94      zUser claims verification failed)rrrr�BAD_REQUESTr.r
  95  r
  96  r�*default_token_verification_failed_callback�r#r1cC�tjS)z�
  97      By default, the decode key specified via the JWT_SECRET_KEY or
  98      JWT_PUBLIC_KEY settings will be used to decode all tokens
  99      )rZ
 100  decode_keyr&r
 101  r
 102  r�default_decode_key_callback��r3r*cCr2)z�
 103      By default, the encode key specified via the JWT_SECRET_KEY or
 104      JWT_PRIVATE_KEY settings will be used to encode all tokens
 105      )rZ
 106  encode_key)r*r
 107  r
 108  r�default_encode_key_callback�r4r5N)�__doc__�httpr�typingrZflaskrZflask.typingrZflask_jwt_extended.configr�dictr
 109  �boolrrrr�strr"r$r'r(r,r/r1r3r5r
 110  r
 111  r
 112  r�<module>sd��
 113  �
 114  
 115  
 116  ��
 117  �
 118  ��
 119  �
 120  ��
 121  �
 122  ��
 123  �
 124