o
    b                     @   s2   d dl mZ 	dddZdddZ	dd	d
ZdS )    )TemporaryCredentialtemporary_credential:c                    sl    fdd} fdd} fdd} fdd}|  d	| |  d
| |  d| |  d| dS )zRegister temporary credential related hooks to authorization server.

    :param authorization_server: AuthorizationServer instance
    :param cache: Cache instance
    :param key_prefix: key prefix for temporary credential
    c                    s8   | d  }|| d< |r|| d<  j || dd t| S )Noauth_token	client_idZoauth_callbackQ timeout)setr   )tokenr   Zredirect_urikeycache
key_prefix f/var/www/secure340b-portal/env/lib/python3.10/site-packages/authlib/integrations/flask_oauth1/cache.pycreate_temporary_credential   s   zHregister_temporary_credential_hooks.<locals>.create_temporary_credentialc                    s*   | sd S |  }  |}|rt|S d S N)getr   )r   r   valuer   r   r   get_temporary_credential   s   
zEregister_temporary_credential_hooks.<locals>.get_temporary_credentialc                    s   | r|  }  | d S d S r   )delete)r   r   r   r   r   delete_temporary_credential   s   zHregister_temporary_credential_hooks.<locals>.delete_temporary_credentialc                    s4   |    }|| d< | | d<  j|| dd | S )NZoauth_verifierZuser_idr   r   )Zget_oauth_tokenZget_user_idr	   )Z
credentialZ
grant_userZverifierr   r   r   r   create_authorization_verifier#   s
   zJregister_temporary_credential_hooks.<locals>.create_authorization_verifierr   r   r   r   N)register_hook)authorization_serverr   r   r   r   r   r   r   r   r   #register_temporary_credential_hooks   s    		r   nonce:r   c                    s    fdd}|S )zCreate an ``exists_nonce`` function that can be used in hooks and
    resource protector.

    :param cache: Cache instance
    :param key_prefix: key prefix for temporary credential
    :param expires: Expire time for nonce
    c                    s>   d | ||}|rd ||} |} j|dd |S )Nz
{}{}-{}-{}z{}-{}   r   )formathasr	   )nonce	timestampr   r   r   rvr   expiresr   r   r   exists_nonce<   s   
z.create_exists_nonce_func.<locals>.exists_noncer   )r   r   r$   r%   r   r#   r   create_exists_nonce_func4   s   r&   c                 C   s   t |||}| d| dS )zRegister nonce related hooks to authorization server.

    :param authorization_server: AuthorizationServer instance
    :param cache: Cache instance
    :param key_prefix: key prefix for temporary credential
    :param expires: Expire time for nonce
    r%   N)r&   r   )r   r   r   r$   r%   r   r   r   register_nonce_hooksF   s   	r'   N)r   )r   r   )Zauthlib.oauth1r   r   r&   r'   r   r   r   r   <module>   s    

0