%PDF- %PDF-
Direktori : /lib/python3/dist-packages/jwt/__pycache__/ |
Current File : //lib/python3/dist-packages/jwt/__pycache__/jwks_client.cpython-312.pyc |
� d��d� � � � d dl Z d dlZd dlmZ d dlmZmZmZm Z d dl mZ ddlm Z mZ ddlmZ ddlmZmZ dd lmZ G d � d� Zy)� N)� lru_cache)�Any�Dict�List�Optional)�URLError� )�PyJWK�PyJWKSet)�decode_complete)�PyJWKClientConnectionError�PyJWKClientError)�JWKSetCachec �� � e Zd Z ddedededededeeeef defd �Z d efd�Z dded efd �Zdded e e fd�Zded efd�Zded efd�Zede e ded ee fd�� Zy)�PyJWKClientN�uri� cache_keys�max_cached_keys� cache_jwk_set�lifespan�headers�timeoutc �� � |�i }|| _ d | _ || _ || _ |r%|dk rt d|� d�� �t |� | _ nd | _ |r" t |�� | j � | _ y y )Nr z/Lifespan must be greater than 0, the input is "�")�maxsize)r � jwk_set_cacher r r r r �get_signing_key)�selfr r r r r r r s �1/usr/lib/python3/dist-packages/jwt/jwks_client.py�__init__zPyJWKClient.__init__ s� � � �?��G����48���������� �1�}�&�E�h�Z�q�Q�� � "-�X�!6�D��!%�D��� $F�9�_�#E�d�FZ�FZ�#[�D� � � �returnc � � d } t j j | j | j �� }t j j || j �� 5 }t j |� }d d d � || j �| j j |� S S # 1 sw Y �3xY w# t t f$ r}t d|� d�� �d }~ww xY w# | j �| j j |� w w xY w)N)�urlr )r z'Fail to fetch data from the url, err: "r )�urllib�request�Requestr r �urlopenr �json�loadr �putr �TimeoutErrorr )r �jwk_set�r�response�es r � fetch_datazPyJWKClient.fetch_data/ s� � ��� 0����&�&�4�8�8�T�\�\�&�J�A����'�'��4�<�<�'�@� .�H��)�)�H�-�� .� ��!�!�-��"�"�&�&�w�/� .� .� .���,�'� �,�9�!��A�>�� �� �� �!�!�-��"�"�&�&�w�/� .�sB �A B8 �$B,�:B8 �C �,B5�1B8 �8C�C�C�C �*D�refreshc �� � d }| j �|s| j j � }|�| j � }t |t � st d� �t j |� S )Nz.The JWKS endpoint did not return a JSON object)r �getr1 � isinstance�dictr r � from_dict)r r2 �datas r �get_jwk_setzPyJWKClient.get_jwk_set? sa � ������)�'��%�%�)�)�+�D��<��?�?�$�D��$��%�"�#S�T�T��!�!�$�'�'r! c � � | j |� }|j D �cg c] }|j dv r|j r|�� }}|st d� �|S c c}w )N)�sigNz2The JWKS endpoint did not contain any signing keys)r9 �keys�public_key_use�key_idr )r r2 r- �jwk_set_key�signing_keyss r �get_signing_keyszPyJWKClient.get_signing_keysL sg � ��"�"�7�+�� '�|�|� ���)�)�]�:�{�?Q�?Q� � �� � �"�#W�X�X���� s �#A�kidc � � | j � }| j ||� }|s5| j d�� }| j ||� }|st d|� d�� �|S )NT)r2 z,Unable to find a signing key that matches: "r )rA � match_kidr )r rB r@ �signing_keys r r zPyJWKClient.get_signing_keyY sj � ��,�,�.���n�n�\�3�7����0�0��0�>�L��.�.��s�;�K��&�B�3�%�q�I�� � �r! �tokenc �j � t |ddi�� }|d }| j |j d� � S )N�verify_signatureF)�options�headerrB )�decode_tokenr r4 )r rF � unverifiedrJ s r �get_signing_key_from_jwtz$PyJWKClient.get_signing_key_from_jwti s8 � �!�%�2D�e�1L�M� ��H�%���#�#�F�J�J�u�$5�6�6r! r@ c �@ � d }| D ] }|j |k( s�|} |S |S )N)r>