Server IP : 15.235.198.142 / Your IP : 216.73.216.190 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ballsack 6.8.0-45-generic #45-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 30 12:02:04 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/oauthlib/oauth1/rfc5849/__pycache__/ |
Upload File : |
� �McL} � �� � d Z ddlZddlZddlZddlZddlZddlmZ ddl Z ddl mZmZm Z ddlmZ ej e� Zdededed efd �Zd.deded efd �Z d/d�Zd efd�Zdedededefd�Z d0defd�Zd� Zd0d�Zd� Zd� Zd0d�Zd� Zdefd�Z d0dedefd�Z!i Z"defd�Z#d� Z$deded efd!�Z%ded"efd#�Z&d$� Z'd"efd%�Z(d&� Z)defd'�Z*d"efd(�Z+defd)�Z,d"efd*�Z-d+� Z.d,� Z/d0d-�Z0y)1a� This module is an implementation of `section 3.4`_ of RFC 5849. **Usage** Steps for signing a request: 1. Collect parameters from the request using ``collect_parameters``. 2. Normalize those parameters using ``normalize_parameters``. 3. Create the *base string URI* using ``base_string_uri``. 4. Create the *signature base string* from the above three components using ``signature_base_string``. 5. Pass the *signature base string* and the client credentials to one of the sign-with-client functions. The HMAC-based signing functions needs client credentials with secrets. The RSA-based signing functions needs client credentials with an RSA private key. To verify a request, pass the request and credentials to one of the verify functions. The HMAC-based signing functions needs the shared secrets. The RSA-based verify functions needs the RSA public key. **Scope** All of the functions in this module should be considered internal to OAuthLib, since they are not imported into the "oauthlib.oauth1" module. Programs using OAuthLib should not use directly invoke any of the functions in this module. **Deprecated functions** The "sign_" methods that are not "_with_client" have been deprecated. They may be removed in a future release. Since they are all internal functions, this should have no impact on properly behaving programs. .. _`section 3.4`: https://tools.ietf.org/html/rfc5849#section-3.4 � N)�extract_params�safe_string_equals� urldecode� )�utils�http_method�base_str_uri�%normalized_encoded_request_parameters�returnc � � t j | j � � }|dz }|t j |� z }|dz }|t j |� z }|S )a� Construct the signature base string. The *signature base string* is the value that is calculated and signed by the client. It is also independently calculated by the server to verify the signature, and therefore must produce the exact same value at both ends or the signature won't verify. The rules for calculating the *signature base string* are defined in section 3.4.1.1`_ of RFC 5849. .. _`section 3.4.1.1`: https://tools.ietf.org/html/rfc5849#section-3.4.1.1 �&)r �escape�upper)r r r �base_strings �C/usr/lib/python3/dist-packages/oauthlib/oauth1/rfc5849/signature.py�signature_base_stringr 6 sd � �4 �,�,�{�0�0�2�3�K� �3��K� �5�<�<��-�-�K� �3��K� �5�<�<� E�F�F�K��� �uri�hostc �x � t | t � st d� �t j | � }|j }|j }|j }|j }|j }|st d� �|sd}|j � }|�|j � }|�D|j � }|� d|� �}t j |� }|j }|j }|�t d� � t j |� }t |t j � rd|� d�}nt |t j � r|� }|�"d|cxk rd k st d � � t d � �||fdv r|}n|r|� d|� �}n|}t j ||||d d f� } | j dd� S # t $ r Y ��w xY w)a� Calculates the _base string URI_. The *base string URI* is one of the components that make up the *signature base string*. The ``host`` is optional. If provided, it is used to override any host and port values in the ``uri``. The value for ``host`` is usually extracted from the "Host" request header from the HTTP request. Its value may be just the hostname, or the hostname followed by a colon and a TCP/IP port number (hostname:port). If a value for the``host`` is provided but it does not contain a port number, the default port number is used (i.e. if the ``uri`` contained a port number, it will be discarded). The rules for calculating the *base string URI* are defined in section 3.4.1.2`_ of RFC 5849. .. _`section 3.4.1.2`: https://tools.ietf.org/html/rfc5849#section-3.4.1.2 :param uri: URI :param host: hostname with optional port number, separated by a colon :return: base string URI zuri must be a string.zmissing scheme�/z://zmissing host�[�]r i�� zport out of range))�http�P )�httpsi� �:� � z%20)� isinstance�str� ValueError�urlparse�scheme�hostname�port�path�params�lower� ipaddress� ip_address�IPv6Address�IPv4Address� urlunparse�replace) r r �outputr$ r% r&