Format: application/x-python-code
⬇ Download File (1.3 KB)
   1  o
   2  
   3  Gh_�@s4ddlmZddlmZmZmZddlZdd�ZdS)�)�jsonify)�create_access_token�jwt_required�get_jwt_identityNcCsNd|jd<d|jd<|jddgd�dd	��}|jd
   4  dgd�t�dd
   5  ���}dS)Nzsuper-secretZJWT_SECRET_KEYiZJWT_ACCESS_TOKEN_EXPIRESz
   6  /api/login�POST)�methodscSs�tj�d�}tj�d�}dt�d�����d�}|r|s$tddi�dfSt�|�����}||dkrE||dkrEt|d�}t|d	�d
   7  fStddi�dfS)
   8  N�username�passwordZadmin)rr	�errorzMissing credentialsi�)�identity)�access_token��zInvalid credentialsi�)	�request�json�get�hashlib�sha256�encode�	hexdigestrr)rr	Z	test_userZ	hashed_pwr�r�CC:\Users\shubh\Videos\agent\agent_preprod\modules\authentication.py�login
   9  s�
  10  zconfigure_auth.<locals>.loginz/api/protected�GETcSst�}t|d�dfS)N)Zlogged_in_asr
  11  )rr)�current_userrrr�	protected!sz!configure_auth.<locals>.protected)�config�router)�apprrrrr�configure_auths
  12  
  13  
  14  r)�flaskrZflask_jwt_extendedrrrrrrrrr�<module>s