
    :WfQ                     2    d dl Z d dlZd dlmZ d Zd Zd Zy)    N)settingsc                    | j                   t        j                  j                         t        j                  d      z   t        j                  j                         d}t	        j
                  |t        j                  d      }|S )N
   daysuser_idexpiatHS256)	algorithmiddatetimeutcnow	timedeltajwtencoder   
SECRET_KEY)useraccess_token_payloadaccess_tokens      S/mnt/ACDE16A4DE16673C/PROJECTS/DRIVERZZ/DRIVERZZ_DRIVER_APIS/authentication/auth.pygenerate_access_tokenr      sg    77  '')H,>,>B,GG  '')
 ::2H4G4GSZ[L    c                 :   | j                   t        j                  j                         t        j                  d      z   t        j                  j                         d}t	        j
                  |t        j                  dt        j                  d            }|S )Nr   r   r   r   )r   lifetimer   )r   refresh_token_payloadrefresh_tokens      r   generate_refresh_tokenr       s    77  '')H,>,>B,GG  '') JJ4h6I6IU\gogygy  @B  hC  DMr   c                 @   | j                   j                  d      }|sy 	 |j                  d      d   }t        j                  |t
        j                  d      }|d   S # t        j                  $ r Y y t        j                  j                  $ r Y y t        $ r Y y w xY w)NAuthorization    r   )
algorithmsr	   )headersgetsplitr   decoder   r   ExpiredSignatureError
exceptionsInvalidSignatureError
IndexError)requestauthorization_headerr   payloads       r   verify_tokenr1      s    "??..?	+11#6q9**\8+>+>7S	"#$$ >>//  s   >A B4BBB)r   r   django.confr   r   r    r1    r   r   <module>r4      s     
  	r   