
    k7i!                     n    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K	J
r
  SSKJr   " S	 S
\5      rg)    )ContinueIteration)default_json_headers)ExpiredTokenError)InvalidClaimError)InvalidTokenError)JWTBearerTokenValidator   )IntrospectionEndpointc                   ^   ^  \ rS rSrSrSrSU 4S jjrS rS rS r	S r
S	\S
\4S jrSrU =r$ )JWTIntrospectionEndpoint   a  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(JWTIntrospectionEndpoint):
        def get_jwks(self): ...

        def get_username(self, user_id): ...


    # endpoint dedicated to JWT access token introspection
    authorization_server.register_endpoint(
        MyJWTAccessTokenIntrospectionEndpoint(
            issuer="https://authorization-server.example.org",
        )
    )

    # another endpoint dedicated to refresh token introspection
    authorization_server.register_endpoint(MyRefreshTokenIntrospectionEndpoint)

introspectionc                 6   > [         TU ]  " USU0UD6  Xl        g )Nserver)super__init__issuer)selfr   r   argskwargs	__class__s        ^/home/james-whalen/.local/lib/python3.13/site-packages/authlib/oauth2/rfc9068/introspection.pyr   !JWTIntrospectionEndpoint.__init__,   s    $8v88    c                 z    U R                  U5      nU R                  X5      nU R                  U5      nSU[        4$ )    )authenticate_endpoint_clientauthenticate_tokencreate_introspection_payloadr   )r   requestclienttokenbodys        r   create_endpoint_response1JWTIntrospectionEndpoint.create_endpoint_response0   sF     227; ''8 007D...r   c                 |   U R                  X5        UR                  R                  S5      S;  a
  [        5       e[	        U R
                  SS9nU R                  Ul         UR                  UR                  S   5      nU(       a  U R                  XBU5      (       a  U$ gg! [         a  n[        5       UeSnAff = f)r   token_type_hint)access_tokenNN)r   resource_serverr#   )
check_paramsformgetr   r   r   get_jwksr   r   check_permission)r   r!   r"   	validatorr#   excs         r   r   +JWTIntrospectionEndpoint.authenticate_token=   s    '* <<-.6LL#%%+4;;PTU	!]]		/00g1FGE T**5'BBL C5 ! 	/#%3.	/s   !B! !
B;+B66B;c           
      L   U(       d  SS0$  UR                  5         SSUS   US   US   US	   US   US
   US   S.	nU R                  US   5      =n(       a  XCS'   U$ ! [         a    SS0s $ [         a+  nUR                  S:X  a  [	        5       Ue[        5       UeS nAff = f)NactiveFissTBearer	client_idscopesubaudexpiat)	r4   
token_typer7   r8   r9   r:   r5   r;   r<   username)validater   r   
claim_namer   r   get_username)r   r#   r1   payloadr>   s        r   r    5JWTIntrospectionEndpoint.create_introspection_payloadQ   s    e$$	/NN "{+7^<<<<<

 ((u6686"*J- ! 	%e$$  	/~~&')s2#%3.	/s   A B#/	B#8&BB#c                     [        5       e)zReturn 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.   !JWTIntrospectionEndpoint.get_jwkso   s     "##r   user_idreturnc                     g)zReturns 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   rG   s     r   rA   %JWTIntrospectionEndpoint.get_usernamex   s     r   )r   )N)__name__
__module____qualname____firstlineno____doc__ENDPOINT_NAMEr   r%   r   r    r.   strrA   __static_attributes____classcell__)r   s   @r   r   r      s@    < $M/(<$C C  r   r   N)authlib.common.errorsr   authlib.constsr   authlib.jose.errorsr   r   authlib.oauth2.rfc6750.errorsr   &authlib.oauth2.rfc9068.token_validatorr   rfc7662r
   r   rJ   r   r   <module>r[      s)    3 / 1 1 ; J +t4 tr   