| Server IP : 186.64.123.29 / Your IP : 216.73.217.94 Web Server : LiteSpeed System : Linux house.hostinglat.cl 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 User : tuemp9827 ( 1016) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/sos/policies/auth/__pycache__/ |
Upload File : |
o
O6ufT � @ sl d dl Z zd dlZdZW n ey dZY nw d dlZd dlmZmZ dZdZe � d�Z
G dd � d �ZdS )
� NTF)�datetime� timedeltaz sos-toolsz,urn:ietf:params:oauth:grant-type:device_code�sosc @ sZ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zddd�ZdS )�DeviceAuthorizationClassz$
Device Authorization Class
c C s* d | _ d | _d | _|| _|| _| �� d S �N)�
_access_token�_access_expires_at�&_DeviceAuthorizationClass__device_code�client_identifier_url�token_endpoint�_use_device_code_grant)�selfr
r � r �</usr/lib/python3/dist-packages/sos/policies/auth/__init__.py�__init__ s z!DeviceAuthorizationClass.__init__c C s$ | � � td| j� �� | �� dS )zv
Start the device auth flow. In the future we will
store the tokens in an in-memory keyring.
z<Please visit the following URL to authenticate this device: N)�_request_device_code�print�_verification_uri_complete�poll_for_auth_completion�r
r r r r ) s ��z/DeviceAuthorizationClass._use_device_code_grantc
C s� dt � �}ddi}tstd��z2tj| j||d�}|�� |�� }|�d�| _ |�d�| _
|�d�| _|�d �| _|�d
�| _
W d
S tjyZ } zt�d|j� d|� ���d
}~ww )zm
Initialize new Device Authorization Grant attempt by
requesting a new device code.
z
client_id=zcontent-typez!application/x-www-form-urlencoded�Rpython3-requests is not installed and is required for obtaining device auth token.)�data�headers� user_code�verification_uri�interval�device_code�verification_uri_completezNHTTP request failed while attempting to acquire the tokens.Error returned was � N)�DEVICE_AUTH_CLIENT_ID�REQUESTS_LOADED� Exception�requests�postr
�raise_for_status�json�get�
_user_code�_verification_uri� _intervalr r � HTTPError�status_code)r
r r �res�response�er r r r 7 s6
������z-DeviceAuthorizationClass._request_device_codec
C s� t t| jd�}ts
td��| jdu rut�| j� z9t j
| j|d�}|j}|dkr4t
�d� | �|�� � |dvr>t||j��|dkrP|�� d d
vrPt||j��W n t jjym } zt
�d|� �� W Y d}~nd}~ww | jdu sdS dS )z�
Continuously poll OIDC token endpoint until the user is successfully
authenticated or an error occurs.
)�
grant_type� client_idr r N�r �� z$The SSO authentication is successful)r2 � r3 �error)�authorization_pending� slow_downz)Error was found while posting a request: )�GRANT_TYPE_DEVICE_CODEr r r r! r �time�sleepr) r"