|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/oauth2client/contrib/__pycache__/ |
U
O��g�
� @ sd d Z ddlZddlZddlZddlZddlmZ dZdZe� d�d
dd ��Z
e� d
�ddd��ZdS )z4Helper methods for creating & verifying XSRF tokens.� N)�_helpers� :i � � c C s� t �tj| dd��}|�tjt|�dd�� |�t� |�tj|dd�� |�t� tjt|phtt�� ��dd�}|�|� |� � }t
�|t | �}|S )a� Generates a URL-safe token for the given user, action, time tuple.
Args:
key: secret key to use.
user_id: the user ID of the authenticated user.
action_id: a string identifier of the action they requested
authorization for.
when: the time in seconds since the epoch at which the user was
authorized for this action. If not set the current time is used.
Returns:
A string XSRF protection token.
zutf-8)�encoding)�hmac�newr � _to_bytes�update�str� DELIMITER�int�time�digest�base64�urlsafe_b64encode)�key�user_id� action_id�whenZdigesterr �token� r �J/opt/cppython/lib/python3.8/site-packages/oauth2client/contrib/xsrfutil.py�generate_token s
r � c
C s� |sdS z t �|�}t|�t�d �}W n tttjfk
rF Y dS X |dkrXt � � }|| t
krhdS t| |||d�}t|�t|�kr�dS d}t
t|�t|��D ]\} }
|| |
A O }q�| S )aR Validates that the given token authorizes the user for the action.
Tokens are invalid if the time of issue is too old or if the token
does not match what generateToken outputs (i.e. the token was forged).
Args:
key: secret key to use.
token: a string of the token generated by generateToken.
user_id: the user ID of the authenticated user.
action_id: a string identifier of the action they requested
authorization for.
Returns:
A boolean - True if the user is authorized for the action, False
otherwise.
F���N)r r r )r �urlsafe_b64decoder
�splitr � TypeError�
ValueError�binascii�Errorr �DEFAULT_TIMEOUT_SECSr �len�zip� bytearray)r r r r �current_time�decodedZ
token_timeZexpected_tokenZ different�x�yr r r �validate_token<