Ë
    ”Âi£  ã                   ó~   — d dl mZ ddlmZ ddlmZ ddlmZ ddlmZ  G d„ de«      Z	 G d	„ d
«      Z
 G d„ d«      Zy)é    )Údefault_json_headersé   )ÚInvalidRequestError)ÚHookable)Úhooked)ÚOAuth2Requestc                   óf   ‡ — e Zd ZdgZdZeZdefˆ fd„Ze	d„ «       Z
	 	 	 	 	 d
d„Zd„ Zd„ Zd	„ Zˆ xZS )Ú	BaseGrantÚclient_secret_basicNÚrequestc                 óZ   •— t         ‰| �  «        d | _        d | _        || _        || _        y ©N)ÚsuperÚ__init__ÚpromptÚredirect_urir   Úserver)Úselfr   r   Ú	__class__s      €úZ/var/www/timesheet/venv/lib/python3.12/site-packages/authlib/oauth2/rfc6749/grants/base.pyr   zBaseGrant.__init__   s+   ø€ Ü‰ÑÔØˆŒØ ˆÔØˆŒØˆ�ó    c                 ó.   — | j                   j                  S r   )r   Úclient©r   s    r   r   zBaseGrant.client   s   € à�|‰|×"Ñ"Ð"r   c                 óˆ   — |€| j                   }| j                  j                  | j                  j                  |||||¬«      S )N)r   Ú
grant_typeÚuserÚscopeÚ
expires_inÚinclude_refresh_token)Ú
GRANT_TYPEr   Úgenerate_tokenr   r   )r   r   r   r   r   r    s         r   r"   zBaseGrant.generate_token!   sK   € ð ÐØŸ™ˆJØ�{‰{×)Ñ)Ø—<‘<×&Ñ&Ø!ØØØ!Ø"7ð *ó 
ð 	
r   c                 ó¢   — | j                   j                  | j                  | j                  «      }| j                   j	                  d|| ¬«       |S )a  Authenticate client with the given methods for token endpoint.

        For example, the client makes the following HTTP request using TLS:

        .. code-block:: http

            POST /token HTTP/1.1
            Host: server.example.com
            Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
            Content-Type: application/x-www-form-urlencoded

            grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
            &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb

        Default available methods are: "none", "client_secret_basic" and
        "client_secret_post".

        :return: client
        Úafter_authenticate_client)r   Úgrant)r   Úauthenticate_clientr   ÚTOKEN_ENDPOINT_AUTH_METHODSÚsend_signal)r   r   s     r   Ú"authenticate_token_endpoint_clientz,BaseGrant.authenticate_token_endpoint_client4   sI   € ð( —‘×0Ñ0Ø�L‰L˜$×:Ñ:ó
ˆð 	�‰×ÑÐ ;ÀFÐRVÐÔWØˆr   c                 óN   — | j                   j                  || j                  «      S )z%A method to save token into database.)r   Ú
save_tokenr   )r   Útokens     r   r+   zBaseGrant.save_tokenN   s   € à�{‰{×%Ñ% e¨T¯\©\Ó:Ð:r   c                 óx   — | j                   j                  j                  }| j                  j	                  |«      S )zAValidate if requested scope is supported by Authorization Server.)r   Úpayloadr   r   Úvalidate_requested_scope)r   r   s     r   r/   z"BaseGrant.validate_requested_scopeR   s,   € à—‘×$Ñ$×*Ñ*ˆØ�{‰{×3Ñ3°EÓ:Ð:r   )NNNNT)Ú__name__Ú
__module__Ú__qualname__r'   r!   r   ÚTOKEN_RESPONSE_HEADERr   r   Úpropertyr   r"   r)   r+   r/   Ú__classcell__)r   s   @r   r
   r
   	   s`   ø„ à#8Ð"9Ðð €Jð 1Ðð õ ð ñ#ó ð#ð
 ØØØØ"ó
ò&ò4;ö;r   r
   c                   ó8   — e Zd ZdgZdZedefd„«       Zd„ Zd„ Z	y)ÚTokenEndpointMixinÚPOSTNr   c                 ó|   — |j                   j                  | j                  k(  xr |j                  | j                  v S r   )r.   r   r!   ÚmethodÚTOKEN_ENDPOINT_HTTP_METHODS©Úclsr   s     r   Úcheck_token_endpointz'TokenEndpointMixin.check_token_endpoint_   s7   € ð �O‰O×&Ñ&¨#¯.©.Ñ8ò BØ—‘ #×"AÑ"AÐAð	
r   c                 ó   — t        «       ‚r   ©ÚNotImplementedErrorr   s    r   Úvalidate_token_requestz)TokenEndpointMixin.validate_token_requestf   ó   € Ü!Ó#Ð#r   c                 ó   — t        «       ‚r   r@   r   s    r   Úcreate_token_responsez(TokenEndpointMixin.create_token_responsei   rC   r   )
r0   r1   r2   r;   r!   Úclassmethodr   r>   rB   rE   © r   r   r7   r7   X   s4   „ à#) (Ðð €Jàð
¨=ò 
ó ð
ò$ó$r   r7   c                   ó‚   — e Zd Z e«       ZdZedefd„«       Ze	defd„«       Z
e	defd„«       Zed„ «       Zd„ Zdefd	„Zy
)ÚAuthorizationEndpointMixinFr   c                 óF   — |j                   j                  | j                  v S r   )r.   Úresponse_typeÚRESPONSE_TYPESr<   s     r   Úcheck_authorization_endpointz7AuthorizationEndpointMixin.check_authorization_endpointq   s   € à�‰×,Ñ,°×0BÑ0BÐBÐBr   c                 óT  — | j                   j                  r^|j                  | j                   j                  «      s#t        d| j                   j                  › d�«      ‚| j                   j                  S |j	                  «       }|s!t        d| j                   j
                  ¬«      ‚|S )NzRedirect URI z is not supported by client.z"Missing 'redirect_uri' in request.©Ústate)r.   r   Úcheck_redirect_urir   Úget_default_redirect_urirP   )r   r   r   s      r   Ú#validate_authorization_redirect_uriz>AuthorizationEndpointMixin.validate_authorization_redirect_uriu   s“   € à�?‰?×'Ò'Ø×,Ñ,¨W¯_©_×-IÑ-IÔJÜ)Ø# G§O¡O×$@Ñ$@Ð#AÐA]Ð^óð ð —?‘?×/Ñ/Ð/à!×:Ñ:Ó<ˆLÙÜ)Ø8ÀÇÁ×@UÑ@Uôð ð  Ðr   c                 óÌ   — | j                   j                  }g d¢}|D ]E  }t        |j                  |g «      «      dkD  sŒ"t	        d|› d�| j                   j
                  ¬«      ‚ y)zÕFor the Authorization Endpoint, request and response parameters MUST NOT be included
        more than once. Per `Section 3.1`_.

        .. _`Section 3.1`: https://tools.ietf.org/html/rfc6749#section-3.1
        )rK   Ú	client_idr   r   rP   é   z
Multiple 'z' in request.rO   N)r.   ÚdatalistÚlenÚgetr   rP   )r   rW   Ú
parametersÚparams       r   Ú&validate_no_multiple_request_parameterzAAuthorizationEndpointMixin.validate_no_multiple_request_parameter…   sd   € ð —?‘?×+Ñ+ˆÚUˆ
Øò 	ˆEÜ�8—<‘<  rÓ*Ó+¨aÓ/Ü)Ø    }Ð5¸W¿_¹_×=RÑ=Rôð ñ	r   c                 ó4   — | j                  «       }|| _        |S r   )Úvalidate_authorization_requestr   )r   r   s     r   Úvalidate_consent_requestz3AuthorizationEndpointMixin.validate_consent_request”   s   € à×:Ñ:Ó<ˆØ(ˆÔØÐr   c                 ó   — t        «       ‚r   r@   r   s    r   r^   z9AuthorizationEndpointMixin.validate_authorization_requestš   rC   r   r   c                 ó   — t        «       ‚r   r@   )r   r   Ú
grant_users      r   Úcreate_authorization_responsez8AuthorizationEndpointMixin.create_authorization_response�   rC   r   N)r0   r1   r2   ÚsetrL   ÚERROR_RESPONSE_FRAGMENTrF   r   rM   ÚstaticmethodrS   r\   r   r_   r^   Ústrrc   rG   r   r   rI   rI   m   s†   „ Ù“U€NØ#ÐàðC°=ò Có ðCð ð °]ò  ó ð ð ð¸ò ó ðð ñó ðò
$ð$¸#ô $r   rI   N)Úauthlib.constsr   Úerrorsr   Úhooksr   r   Úrequestsr   r
   r7   rI   rG   r   r   ú<module>rl      s7   ðÝ /å (Ý Ý Ý $ôL;�ô L;÷^$ñ $÷*1$ò 1$r   