� u��g:����ddlZddlZddlZddlZddlZeje��Zd�Zd�Z Gd�de ��Z Gd�de ��Z Gd�d e ��Z e Ze Ze je_dS) �Nc�B� |�d���S#|cYSxYw)Nzutf-8)�encoding)�encode)�raws �h/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/msal/oauth2cli/assertion.py� _str2bytesr s-����z�z�7�z�+�+�+���� � � ���s��c�r�tjtj|�������S�N)�base64�urlsafe_b64encode�binascii�a2b_hex�decode)� thumbprints r�_encode_thumbprintrs*�� � #�H�$4�Z�$@�$@� A� A� H� H� J� J�J�c�$�eZdZ dd�Z dd�ZdS)�AssertionCreatorN�Xc � �td���)a+Create an assertion in bytes, based on the provided claims. All parameter names are defined in https://tools.ietf.org/html/rfc7521#section-5 except the expires_in is defined here as lifetime-in-seconds, which will be automatically translated into expires_at in UTC. z Will be implemented by sub-class)�NotImplementedError) �self�audience�issuer�subject� expires_at� expires_in� issued_at� assertion_id�kwargss r�create_normal_assertionz(AssertionCreator.create_normal_assertions��"�"D�E�E�Erc �Z��t|||||f�fd� t|dz d�����S)z�Create an assertion as a callable, which will then compute the assertion later when necessary. This is a useful optimization to reuse the client assertion. c�(���j|||fd|i|��S)Nr)r!)�a�i�s�er rs �r�<lambda>z@AssertionCreator.create_regenerative_assertion.<locals>.<lambda>)s)���,��,�Q��1�M�M��M�f�M�M�r�<r)r)� AutoRefresher�max)rrrrrr s` r�create_regenerative_assertionz.AssertionCreator.create_regenerative_assertion!sV������7�j�� N� N� N� N� N��:�b�=�!�,�,�.�.�.� .r)NrNN)Nr)�__name__� __module__� __qualname__r!r,�rrrrsL������IL�)-� F� F� F� F�>A� .� .� .� .� .� .rrc� �eZdZdZdd�Zd�ZdS)r*aCache the output of a factory, and auto-refresh it when necessary. Usage:: r = AutoRefresher(time.time, expires_in=5) for i in range(15): print(r()) # the timestamp change only after every 5 seconds time.sleep(1) �c�0�||_||_i|_dSr )�_factory� _expires_in�_buf)r�factoryrs r�__init__zAutoRefresher.__init__6s���� �%����� � � rc�X�d\}}tj��}|j�|d��|kr@t�d��||���|||jzi|_nt�d��|j�|��S)N)r�valuerzRegenerating new assertionzReusing still valid assertion)�timer6�get�logger�debugr4r5)r� EXPIRES_AT�VALUE�nows r�__call__zAutoRefresher.__call__:s���1�� �E��i�k�k�� �9�=�=��Q� '� '�3� .� .� �L�L�5� 6� 6� 6��� � ����S�4�CS�=S�T�D�I�I� �L�L�8� 9� 9� 9��y�}�}�U�#�#�#rN)r2)r-r.r/�__doc__r8rBr0rrr*r*.sA������������$�$�$�$�$rr*c�,�eZdZ ddd�d�Z dd�ZdS)�JwtAssertionCreatorN)�sha256_thumbprintc��||_||_|pi|_|rt|��|jd<|rt|��|jd<dSdS)a6Construct a Jwt assertion creator. Args: key (str): An unencrypted private key for signing, in a base64 encoded string. It can also be a cryptography ``PrivateKey`` object, which is how you can work with a previously-encrypted key. See also https://github.com/jpadilla/pyjwt/pull/525 algorithm (str): "RS256", etc.. See https://pyjwt.readthedocs.io/en/latest/algorithms.html RSA and ECDSA algorithms require "pip install cryptography". sha1_thumbprint (str): The x5t aka X.509 certificate SHA-1 thumbprint. headers (dict): Additional headers, e.g. "kid" or "x5c" etc. sha256_thumbprint (str): The x5t#S256 aka X.509 certificate SHA-256 thumbprint. zx5t#S256�x5tN)�key� algorithm�headersr)rrIrJ�sha1_thumbprintrKrFs rr8zJwtAssertionCreator.__init__Fsj��*���"����}�"�� � � M�'9�:K�'L�'L�D�L�� $� � F�"4�_�"E�"E�D�L�� � � � F� Frrc ���ddl} tj��} |||p||p| |z|p| |pttj����d�} |r|| d<| �| pi�� | �| |j|j|j ���}t|��S#|j� d��s|j� d��rt� d���xYw) z�Create a JWT Assertion. Parameters are defined in https://tools.ietf.org/html/rfc7523#section-3 Key-value pairs in additional_claims will be added into payload as-is. rN)�aud�iss�sub�exp�iat�jti�nbf)rJrK�RS�ESz�Some algorithms requires "pip install cryptography". See https://pyjwt.readthedocs.io/en/latest/installation.html#cryptographic-dependencies-optional)�jwtr;�str�uuid�uuid4�updaterrIrJrKr� startswithr=� exception)rrrrrrrr� not_before�additional_claimsr rWrA�payload� str_or_bytess rr!z+JwtAssertionCreator.create_normal_assertioncs$�� � � � ��i�k�k�����$�f��3�#� �"2��#���4�3�t�z�|�|�#4�#4� ��� � (�'�G�E�N����(�.�B�/�/�/� ��:�:����T�^�T�\�&�S�S�L��l�+�+� +�� ��~�(�(��.�.� x�$�.�2K�2K�D�2Q�2Q� x�� � �w�x�x�x� ���s �)6B � AC1)NN)NNrNNNN)r-r.r/r8r!r0rrrErEEsa������<@�F��F�F�F�F�F�<OR�:>�"������rrE)r;r r rY�logging� getLoggerr-r=rr�objectrr*rE�Signer� JwtSignerr!�sign_assertionr0rr�<module>rhs�� � � � ����� � � � � � � � ����� �� �8� $� $�����K�K�K�.�.�.�.�.�v�.�.�.�2$�$�$�$�$�F�$�$�$�.=�=�=�=�=�*�=�=�=�B �� � �.�F� ���r
Memory