
    ch!                        S SK Jr  S SKJr  S SKJrJrJr  S SKJrJ	r	J
r
Jr  S SKJr  S SKJr  S SKJrJr  \(       a   " S S	\
5      r " S
 S5      rSS jrSS jrSS jrSS jrSS jrSS jrSS jrg)    )annotations)Mapping)datetime	timedeltatimezone)TYPE_CHECKINGAny	TypedDictcast)config)StreamlitAuthError)AttrDictsecrets_singletonc                  *    \ rS rSr% S\S'   S\S'   Srg)ProviderTokenPayload   strproviderintexp N)__name__
__module____qualname____firstlineno____annotations____static_attributes__r       fC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\streamlit/auth_util.pyr   r      s    r   r   c                  N    \ rS rSrSrS
S jrSS jrSSS jjrSS jrSS jr	S	r
g)	AuthCache    zBSimple cache implementation for storing info required for Authlib.c                    0 U l         g Ncacheselfs    r   __init__AuthCache.__init__#   s	    %'
r   c                8    U R                   R                  U5      $ r$   )r&   getr(   keys     r   r,   AuthCache.get&   s    zz~~c""r   Nc                     X R                   U'   g r$   r%   )r(   r.   value
expires_ins       r   setAuthCache.set+   s    

3r   c                    U R                   $ r$   r%   r'   s    r   get_dictAuthCache.get_dict.   s    zzr   c                <    U R                   R                  US 5        g r$   )r&   popr-   s     r   deleteAuthCache.delete1   s    

sD!r   r%   )returnNone)r.   r   r<   r	   r$   )r.   r   r1   r	   r2   z
int | Noner<   r=   )r<   dict[str, Any])r.   r   r<   r=   )r   r   r   r   __doc__r)   r,   r3   r6   r:   r   r   r   r   r!   r!       s    L(#
 "r   r!   c                      SSK n U R                  n[        [        [        UR                  S5      5      5      nUS:  a  g g! [        [        4 a     gf = f)zCheck if Authlib is installed.r   N.)         FT)authlib__version__tuplemapr   splitImportErrorModuleNotFoundError)rE   authlib_versionauthlib_version_tuples      r   is_authlib_installedrN   5   sa    	!-- %c#/D/DS/I&J K 9, -  ,- s   >A AAc                     [         R                  " S5      n [        R                  " 5       (       a/  [        R                  " S5      nU(       a  UR	                  SU 5      n U $ )zEGet the cookie signing secret from the configuration or secrets.toml.zserver.cookieSecretauthcookie_secret)r   
get_optionr   load_if_toml_existsr,   )signing_secretauth_sections     r   get_signing_secretrV   D   sM     ++,ABN,,..(,,V4)--o~NNr   c                     [        0 5      n  [        R                  " 5       (       a   [        S[        R                  " S5      5      n U $ )Nr   rP   )r   r   rS   r   r,   )rU   s    r   get_secrets_auth_sectionrX   N   s;    B<L5,,..J(9(=(=f(EFr   c                    SSK Jn  SS0nU [        R
                  " [        R                  5      [        SS9-   S	.nUR                  X#[        5       5      nUR                  S
5      $ ! [         a    [        S5      Sef = f)zAReturns a signed JWT token with the provider and expiration time.r   )jwtcTo use authentication features, you need to install Authlib>=1.3.2, e.g. via `pip install Authlib`.NalgHS256rD   )minutes)r   r   zlatin-1)authlib.joserZ   rJ   r   r   nowr   utcr   encoderV   decode)r   rZ   headerpayloadprovider_tokens        r   encode_provider_tokenrg   W   s    $ WF||HLL)Ia,@@G  JJv8J8LMN  ++   u
	s   A( (A?c                    SSK JnJnJn  SS0SS0S.n UR                  U [        5       US9nUR                  5         [        S
U5      $ ! [         a    [        S5      Sef = f! U a  n[        S	U 35      SeSnAff = f)z-Decode the JWT token and validate the claims.r   )	JoseError	JWTClaimsrZ   r[   N	essentialT)r   r   )claims_optionszError decoding provider token: r   )
r_   ri   rj   rZ   rJ   r   rc   rV   validater   )rf   ri   rj   rZ   claim_optionsre   es          r   decode_provider_tokenrp   j   s    :: )$/k4=PQMR ZZ.0 ( 
 	 &00!   u
	  R #B1#!FGTQRs"   
A )A% A"%A?+A::A?c           	        0 nU R                  S5      (       a  U R                  S5      US'   U R                  S5      (       a  U R                  S5      US'   U R                  S5      (       a  U R                  S5      US'   U R                  S5      (       a6  [        SU R                  S[        0 5      5      5      R                  5       US'   U$ )zKGenerate a default provider section for the 'auth' section of secrets.toml.	client_idclient_secretserver_metadata_urlclient_kwargsr   )r,   r   r   to_dict)rU   default_provider_sections     r   !generate_default_provider_sectionrx      s    !$$0<0@0@0M -((4@4D4D_4U 1-..:F:J:J!;
 !67 ((48(((2,G5

') 	!1 $#r   c                |   [         R                  " 5       (       d  [        S5      e[         R                  " S5      nUc  [        S5      eSU;  a  [        S5      eSU;  a  [        S5      eUR                  U 5      nSU ;   a  [        S	U  S
35      eUc  U S:X  a  [	        U5      nUc   U S:X  a  [        S5      e[        SU  S35      e[        U[        5      (       d  [        SU  S35      e/ SQnU Vs/ s H  oDU;  d  M
  UPM     nnU(       a'  U S:X  a  [        SU S35      e[        SU  SU S35      egs  snf )zSValidate the general auth credentials and auth credentials for the given
provider.
zTo use authentication features you need to configure credentials for at
            least one authentication provider in `.streamlit/secrets.toml`.rP   Nredirect_urizAuthentication credentials in `.streamlit/secrets.toml` are missing the
            "redirect_uri" key. Please check your configuration.rQ   zAuthentication credentials in `.streamlit/secrets.toml` are missing the
            "cookie_secret" key. Please check your configuration._zAuth provider name "zI" contains an underscore. Please use a provider name without underscores.defaultzAuthentication credentials in `.streamlit/secrets.toml` are missing for
                the default authentication provider. Please check your configuration.zeAuthentication credentials in `.streamlit/secrets.toml` are missing for the authentication provider "z#". Please check your configuration.zYAuthentication credentials in `.streamlit/secrets.toml` for the authentication provider "z6" must be valid TOML. Please check your configuration.)rr   rs   rt   zAuthentication credentials in `.streamlit/secrets.toml` for the default authentication provider are missing the following keys: z". Please check your configuration.z"" are missing the following keys: )r   rS   r   r,   rx   
isinstancer   )r   rU   provider_sectionrequired_keysr.   missing_keyss         r   validate_auth_credentialsr      s    0022 O
 	

 %((0L O
 	
 \) D
 	
 l* E
 	

 $''1 h "8* -> ?
 	

 H	$9<\Jy $Y  !,,4: 6
 	
 &00 ((0z 2"#
 	
 JM#0P=C?O4OC=LPy $S. BD 
 !((0z1Sn>@
 	
  Qs   5	D9D9N)r<   bool)r<   r   )r<   r   )r   r   r<   r   )rf   r   r<   r   )rU   r   r<   r>   )r   r   r<   r=   )
__future__r   collections.abcr   r   r   r   typingr   r	   r
   r   	streamlitr   streamlit.errorsr   streamlit.runtime.secretsr   r   r   r!   rN   rV   rX   rg   rp   rx   r   r   r   r   <module>r      s_    # # 2 2 6 6  / Ay 
" "*,&1.$$H
r   