
    Sњh                         S SK r S SKrS SKJrJrJrJrJr  S SKJ	r	  S SK
Jr  S SKJr  S SKJr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\5      rS\4S jrg)    N)AnyDictIterableLiteralOptional)get_user_modelget_random_secret_key)gettext_lazy)str_to_user_iduser_id_to_struser_username)EmailAddress)BaseAdaptergenerate_user_code)app_settings)import_attributec                       \ rS rSrSr\" S5      \" S5      \" S5      S.rS\4S jrS\4S	 jr	S\4S
 jr
S\S\4S jrS\4S jrS\SS4S jr SS\S   S\S\\   S\\\4   4S jjrS\4S jrS\4S jrSrg)DefaultOIDCAdapter   a/  The adapter class allows you to override various functionality of the
``allauth.idp.oidc`` app.  To do so, point ``settings.IDP_OIDC_ADAPTER`` to
your own class that derives from ``DefaultOIDCAdapter`` and override the
behavior by altering the implementation of the methods according to your own
needs.
zView your user IDzView your email addressz#View your basic profile information)openidemailprofilereturnc                 @    [         R                  " 5       R                  $ )z1
The client ID to use for newly created clients.
)uuiduuid4hexselfs    SD:\Anime\Ugyen\janka_web_project\venv\Lib\site-packages\allauth/idp/oidc/adapter.pygenerate_client_id%DefaultOIDCAdapter.generate_client_id#   s     zz|    c                     [        5       $ )z5
The client secret to use for newly created clients.
r	   r    s    r"   generate_client_secret)DefaultOIDCAdapter.generate_client_secret)   s     %&&r%   c                     [        SS9$ )N   )lengthr   r    s    r"   r   %DefaultOIDCAdapter.generate_user_code/   s    !++r%   tokenc                 h    [         R                  " UR                  S5      5      R                  5       $ )z_
We don't store tokens directly, only the hash of the token. This methods generates
that hash.
zutf-8)hashlibsha256encode	hexdigest)r!   r-   s     r"   
hash_tokenDefaultOIDCAdapter.hash_token2   s%    
 ~~ell734>>@@r%   c                 V    U R                   R                  S5      R                  S5      $ )z 
Returns the URL of the issuer.
/)requestbuild_absolute_urirstripr    s    r"   
get_issuerDefaultOIDCAdapter.get_issuer9   s$     ||..s3::3??r%   id_tokenNc                     g)z
This method can be used to alter the ID token payload. It is already populated
with basic values. Depending on the client and requested scopes, you can
expose additional information here.
N )r!   r<   clientscopeskwargss        r"   populate_id_token$DefaultOIDCAdapter.populate_id_token?   s     	r%   purpose)r<   userinfor@   r   c                 (   SU R                  X25      0nSU;   av  U(       a!   [        R                  R                  X%5      nO[        R                  R                  U5      nW(       a(  UR                  UR                  UR                  S.5        SU;   ab  UR                  5       n	[        USS5      n
[        USS5      n[        U5      nU	UU
US.nUR                  5        H  u  pU(       d  M  XU'   M     U$ ! [        R                   a     Nf = f)	zH
Return the claims to be included in the ID token or userinfo response.
subr   )r   email_verifiedr   	last_nameN
first_name)name
given_namefamily_namepreferred_username)get_user_subr   objectsget_for_userDoesNotExistget_primaryupdater   verifiedget_full_namegetattrr   items)r!   rD   userr?   r@   r   rA   claimsaddress	full_namerI   rJ   usernameprofile_claims	claim_keyclaim_values                   r"   
get_claimsDefaultOIDCAdapter.get_claimsG   s    **689f*22??LG '..::4@!(*1*:*: **,Ik48I |T:J$T*H!((&.	N +9*>*>*@&	;(39% +A 3 $00 s   C: :DDc                     [        U5      $ )z<
Returns the "sub" (subject identifier) for the given user.
)r   )r!   r?   rY   s      r"   rO   DefaultOIDCAdapter.get_user_subs   s     d##r%   rG   c                      [        U5      n[        5       R                  R	                  US9R                  5       nU(       a  UR                  (       d  gU$ ! [         a     gf = f)zZ
Looks up a user, given its subject identifier. Returns `None` if no
such user was found.
N)pk)r   
ValueErrorr   rP   filterfirst	is_active)r!   r?   rG   rf   rY   s        r"   get_user_by_sub"DefaultOIDCAdapter.get_user_by_suby   s]    
	$B ''..".5;;=4>>  		s   A 
A$#A$r>   N)__name__
__module____qualname____firstlineno____doc___scope_displaystrr#   r'   r   r3   r:   dictrB   r   r   r   r   r   ra   rO   rk   __static_attributes__r>   r%   r"   r   r      s     '(,-:;M C  ' ',C ,A A A@C @$ T   $*/0*
 * }* 
c3h*X$C $3 r%   r   r   c                  >    [        [        R                  5      " 5       $ rm   )r   r   ADAPTERr>   r%   r"   get_adapterrz      s    L00133r%   )r/   r   typingr   r   r   r   r   django.contrib.authr   django.core.management.utilsr
   django.utils.translationr   rs    allauth.account.internal.userkitr   r   r   allauth.account.modelsr   allauth.core.internal.adapterr   allauth.core.internal.cryptokitr   allauth.idp.oidcr   allauth.utilsr   r   rz   r>   r%   r"   <module>r      sQ      9 9 . > 6 
 0 5 > ) *p pf4' 4r%   