§
    iÝ[f›  ã                   óv   — 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 ddl	m
Z
 ddlmZ  G d	„ d
e¦  «        ZdS )é   )ÚIntrospectionEndpointé    )ÚContinueIteration)Údefault_json_headers)ÚExpiredTokenError)ÚInvalidClaimError)ÚInvalidTokenError)ÚJWTBearerTokenValidatorc                   óP   ‡ — e Zd ZdZdZdˆ fd„	Zd„ Zd„ Zd„ Zd„ Z	d	e
d
e
fd„Zˆ xZS )ÚJWTIntrospectionEndpointa‹  
    JWTIntrospectionEndpoint inherits from :ref:`specs/rfc7662`
    :class:`~authlib.oauth2.rfc7662.IntrospectionEndpoint` and implements the machinery
    to automatically process the JWT access tokens.

    :param issuer: The issuer identifier for which tokens will be introspected.

    :param \*\*kwargs: Other parameters are inherited from
        :class:`~authlib.oauth2.rfc7662.introspection.IntrospectionEndpoint`.

    ::

        class MyJWTAccessTokenIntrospectionEndpoint(JWTRevocationEndpoint):
            def get_jwks(self):
                ...

            def get_username(self, user_id):
                ...

        authorization_server.register_endpoint(
            MyJWTAccessTokenIntrospectionEndpoint(
                issuer="https://authorization-server.example.org",
            )
        )
        authorization_server.register_endpoint(MyRefreshTokenIntrospectionEndpoint)

    ÚintrospectionNc                 óL   •—  t          ¦   «         j        |d|i|¤Ž || _        d S )NÚserver)ÚsuperÚ__init__Úissuer)Úselfr   r   ÚargsÚkwargsÚ	__class__s        €úX/var/www/piapp/venv/lib/python3.11/site-packages/authlib/oauth2/rfc9068/introspection.pyr   z!JWTIntrospectionEndpoint.__init__*   s/   ø€ Ø�‰ŒÔ˜$Ð8 vÐ8°Ð8Ð8Ð8ØˆŒˆˆó    c                 ó–   — |                       |¦  «        }|                      ||¦  «        }|                      |¦  «        }d|t          fS )Ú éÈ   )Úauthenticate_endpoint_clientÚauthenticate_tokenÚcreate_introspection_payloadr   )r   ÚrequestÚclientÚtokenÚbodys        r   Úcreate_endpoint_responsez1JWTIntrospectionEndpoint.create_endpoint_response.   sQ   € ð ×2Ò2°7Ñ;Ô;ˆð ×'Ò'¨°Ñ8Ô8ˆð ×0Ò0°Ñ7Ô7ˆØ�DÕ.Ð.Ð.r   c                 ó€  — |                       ||¦  «         |j                             d¦  «        dvrt          ¦   «         ‚t	          | j        d¬¦  «        }| j        |_        	 |                     |j        d         ¦  «        }n# t          $ r t          ¦   «         ‚w xY w|r|  	                    |||¦  «        r|S dS dS )r   Útoken_type_hint)Úaccess_tokenNN)r   Úresource_serverr!   )
Úcheck_paramsÚformÚgetr   r
   r   Úget_jwksr   r	   Úcheck_permission)r   r   r    Ú	validatorr!   s        r   r   z+JWTIntrospectionEndpoint.authenticate_token;   sè   € à×Ò˜' 6Ñ*Ô*Ð*ð Œ<×ÒÐ-Ñ.Ô.Ð6LÐLÐLÝ#Ñ%Ô%Ð%å+°4´;ÐPTÐUÑUÔUˆ	Ø!œ]ˆ	Ôð	&Ø×0Ò0°´¸gÔ1FÑGÔGˆEˆEøõ !ð 	&ð 	&ð 	&Ý#Ñ%Ô%Ð%ð	&øøøð ð 	�T×*Ò*¨5°&¸'ÑBÔBð 	ØˆLð	ð 	ð 	ð 	s   Á$ B ÂBc           
      ó~  — |sddiS 	 |                      ¦   «          nH# t          $ r ddicY S t          $ r,}|j        dk    rt	          ¦   «         ‚t          ¦   «         ‚d }~ww xY wdd|d         |d         |d         |d	         |d         |d
         |d         dœ	}|                      |d         ¦  «        x}r||d<   |S )NÚactiveFÚissTÚBearerÚ	client_idÚscopeÚsubÚaudÚexpÚiat)	r/   Ú
token_typer2   r3   r4   r5   r0   r6   r7   Úusername)Úvalidater   r   Ú
claim_namer   r	   Úget_username)r   r!   ÚexcÚpayloadr9   s        r   r   z5JWTIntrospectionEndpoint.create_introspection_payloadO   s
  € Øð 	%Ø˜eÐ$Ð$ð	&Ø�NŠNÑÔÐÐøÝ ð 	%ð 	%ð 	%Ø˜eÐ$Ð$Ð$Ð$Ý ð 	&ð 	&ð 	&ØŒ~ Ò&Ð&Ý'Ñ)Ô)Ð)Ý#Ñ%Ô%Ð%øøøøð	&øøøð Ø"Ø˜{Ô+Ø˜7”^Ø˜”<Ø˜”<Ø˜”<Ø˜”<Ø˜”<ð

ð 

ˆð ×(Ò(¨¨u¬Ñ6Ô6Ð6ˆ8ð 	+Ø"*ˆG�JÑàˆs   ˆ �A"­	A"¶'AÁA"c                 ó   — t          ¦   «         ‚)zÕReturn the JWKs that will be used to check the JWT access token signature.
        Developers MUST re-implement this method::

            def get_jwks(self):
                return load_jwks("jwks.json")
        )ÚNotImplementedError)r   s    r   r+   z!JWTIntrospectionEndpoint.get_jwksn   s   € õ "Ñ#Ô#Ð#r   Úuser_idÚreturnc                 ó   — dS )zÁReturns an username from a user ID.
        Developers MAY re-implement this method::

            def get_username(self, user_id):
                return User.get(id=user_id).username
        N© )r   rA   s     r   r<   z%JWTIntrospectionEndpoint.get_usernamew   s	   € ð ˆtr   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚENDPOINT_NAMEr   r#   r   r   r+   Ústrr<   Ú__classcell__)r   s   @r   r   r   
   s¬   ø€ € € € € ðð ð: $€Mðð ð ð ð ð ð/ð /ð /ðð ð ð(ð ð ð>$ð $ð $ð Cð ¨Cð ð ð ð ð ð ð ð r   r   N)Úrfc7662r   Úauthlib.common.errorsr   Úauthlib.constsr   Úauthlib.jose.errorsr   r   Úauthlib.oauth2.rfc6750.errorsr	   Ú&authlib.oauth2.rfc9068.token_validatorr
   r   rD   r   r   ú<module>rR      sÂ   ðØ +Ð +Ð +Ð +Ð +Ð +Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ø /Ð /Ð /Ð /Ð /Ð /Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ø JÐ JÐ JÐ JÐ JÐ Jðtð tð tð tð tÐ4ñ tô tð tð tð tr   