
    Tњh                     B   S SK r S SKJr  S SKJrJr  S SKJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr  S S	KJrJr  S S
KJr  S SKJr  S SKJrJrJr  \" \S0 5      R9                  S0 5      R9                  SS5      r\" \S0 5      R9                  S0 5      R9                  SS5      r\" \S0 5      R9                  S0 5      R9                  SS5      r\" \S0 5      R9                  S0 5      R9                  SS5      r \" \S0 5      R9                  S0 5      R9                  SS5      r!\" \S0 5      R9                  S0 5      R9                  SS5      r"S S jr# " S S\5      r$\RJ                  " \$5      r&\RJ                  " \$5      r' " S S\5      r(\	" \(RS                  5       5      r*g)!    N)settings)PermissionDeniedValidationError)method_decorator)csrf_exempt)View)login_not_required)get_adapter)complete_social_loginrender_authentication_error)jwtkit)OAuth2Error)OAuth2AdapterOAuth2CallbackViewOAuth2LoginViewSOCIALACCOUNT_PROVIDERSgoogle	CERTS_URLz*https://www.googleapis.com/oauth2/v1/certsIDENTITY_URLz-https://www.googleapis.com/oauth2/v2/userinfoACCESS_TOKEN_URLz#https://oauth2.googleapis.com/tokenAUTHORIZE_URLz,https://accounts.google.com/o/oauth2/v2/authID_TOKEN_ISSUERzhttps://accounts.google.comFETCH_USERINFOFc           	      t    [         R                  " U[        [        U R                  [         R
                  US9$ )N)
credentialkeys_urlissueraudience
lookup_kidverify_signature)r   verify_and_decoder   r   	client_idlookup_kid_pem_x509_certificate)appr   r    s      gD:\Anime\Ugyen\janka_web_project\venv\Lib\site-packages\allauth/socialaccount/providers/google/views.py_verify_and_decoder&   =   s1    ##99)     c                   >    \ rS rSrSr\r\r\	r
\r\rS rS rS rSrg)GoogleOAuth2AdapterH   r   c                 n   S nUR                  S5      nU(       a`  U R                  X'5      nU R                  (       a=  SU;  a7  U R                  UR                  5      nUR                  S5      n	U	(       a  XS'   OU R                  UR                  5      nU R                  5       R                  X5      n
U
$ )Nid_tokenpicture)get_decode_id_tokenfetch_userinfo_fetch_user_infotokenget_providersociallogin_from_response)selfrequestr$   r2   responsekwargsdatar,   infor-   logins              r%   complete_login"GoogleOAuth2Adapter.complete_loginP   s    <<
+((7D""y'<,,U[[9((9-&-O((5D!!#==gLr'   c                 8    U R                   (       + n[        XUS9$ )a  
If the token was received by direct communication protected by
TLS between this library and Google, we are allowed to skip checking the
token signature according to the OpenID Connect Core 1.0 specification.

https://openid.net/specs/openid-connect-core-1_0.html#IDTokenValidation
)r    )did_fetch_access_tokenr&   )r5   r$   r,   r    s       r%   r/   $GoogleOAuth2Adapter._decode_id_token_   s!      $:::!#BRSSr'   c                     [        5       R                  5       R                  U R                  SSR	                  U5      0S9nUR
                  (       d  [        S5      eUR                  5       $ )NAuthorizationz	Bearer {})headerszRequest to user info failed)r
   get_requests_sessionr.   identity_urlformatokr   json)r5   access_tokenresps      r%   r1   $GoogleOAuth2Adapter._fetch_user_infoj   sa    M!!#S!!(+*<*<\*JK   	 ww;<<yy{r'    N)__name__
__module____qualname____firstlineno__provider_idr   access_token_urlr   authorize_urlr   id_token_issuerr   rE   r   r0   r<   r/   r1   __static_attributes__rL   r'   r%   r)   r)   H   s1    K'!M%OL#N	Tr'   r)   c                   P   ^  \ rS rSr\" \5      U 4S j5       rS rS rS r	Sr
U =r$ )LoginByTokenView|   c                 *  > [        5       U l        U R                  R                  U[        R                  5      U l         [        TU ]  U5      $ ! [        [        R                  [        [        4 a  n[        XR
                  US9s S nA$ S nAff = f)N)	exception)r
   adapterr3   r)   rQ   providersuperdispatchr   requestsRequestExceptionr   r   r   )r5   r6   exc	__class__s      r%   r^   LoginByTokenView.dispatch}   s~    "}11(44
	V7#G,,%%	
 	V /wQTUU	Vs   A $B4BBBc                     [        S5      e)N405)r   )r5   r6   s     r%   r.   LoginByTokenView.get   s     u%%r'   c                     U R                  U5        UR                  R                  S5      nU R                  R	                  USU05      n[        X5      $ )Nr   r,   )
check_csrfPOSTr.   r\   verify_tokenr   )r5   r6   argsr8   r   r;   s         r%   postLoginByTokenView.post   sH     \\%%l3
**7Z4LM$W44r'   c                     UR                   R                  S5      nU(       d  [        S5      eUR                  R                  S5      nU(       d  [        S5      eX#:w  a  [        S5      eg )Ng_csrf_tokenzNo CSRF token in Cookie.zNo CSRF token in post body.z&Failed to verify double submit cookie.)COOKIESr.   r   ri   )r5   r6   csrf_token_cookiecsrf_token_bodys       r%   rh   LoginByTokenView.check_csrf   s`    #OO//? "#=>>!,,**>:"#@AA/"#KLL 0r'   )r[   r\   )rM   rN   rO   rP   r   r	   r^   r.   rl   rh   rU   __classcell__)rb   s   @r%   rW   rW   |   s3    ()V *V&
5M Mr'   rW   )T)+r_   django.confr   django.core.exceptionsr   r   django.utils.decoratorsr   django.views.decorators.csrfr   django.views.genericr   #allauth.account.internal.decoratorsr	   allauth.socialaccount.adapterr
   allauth.socialaccount.helpersr   r   allauth.socialaccount.internalr   -allauth.socialaccount.providers.oauth2.clientr   ,allauth.socialaccount.providers.oauth2.viewsr   r   r   getattrr.   r   r   r   r   r   r   r&   r)   adapter_viewoauth2_loginoauth2_callbackrW   as_viewlogin_by_tokenrL   r'   r%   <module>r      s      D 4 4 % B 5 2 E  H/4S2SBC 
 H/4S2SHI  H/4S2S	BC  H/4S2SHI  H/4S2S	9:  H/4S2S	5! -- -` ++,?@$112EF%Mt %MP -5578r'   