HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib/python3.10/site-packages/docker/__pycache__/auth.cpython-310.pyc
o

��h�2�@s�ddlZddlZddlZddlmZmZddlmZdZde�d�Z	dZ
e�e�Z
d	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Zd$dd�Zdd�Zdd�Zdd�Zd%dd�Zd&d d!�Zd"d#�ZdS)'�N�)�credentials�errors)�configz	docker.iozhttps://index.z/v1/z<token>cCs\d|vr
t�d|�d���t|�\}}|ddks|ddkr(t�d|�d���t|�|fS)	Nz://z)Repository name cannot contain a scheme (�)r�-���zInvalid index name (z%). Cannot begin or end with a hyphen.)r�InvalidRepository�split_repo_name�resolve_index_name)�	repo_name�
index_name�remote_name�r�A/usr/local/CyberPanel/lib/python3.10/site-packages/docker/auth.py�resolve_repository_names
�
�rcCst|�}|dt��kr
t}|S)Nzindex.)�convert_to_hostname�
INDEX_NAME)r
rrrrsrcCsft�d�|jr|jjrt�d�t|jd�|_t|j||jd�}|r,t�d�t|�St�d�dS)NzLooking for auth configz2No auth config in memory - loading from filesystem)�
credstore_envzFound auth configzNo auth config found)�log�debug�
_auth_configs�is_empty�load_configr�resolve_authconfig�
encode_header)�client�registry�authcfgrrr�get_config_header%s
�
�

rcCsL|�dd�}t|�dksd|dvr"d|dvr"|ddkr"t|fSt|�S)N�/r�.r�:�	localhost)�split�lenr�tuple)r�partsrrrr
;s
$r
cCst|t�s	t|�}|�|�S�N)�
isinstance�
AuthConfig�get_credential_store)�
authconfigrrrrr+Es

r+c@s�eZdZddd�Zeddd��Zeddd��Zed	d
��Zedd��Z	ed
d��Z
edd��Zddd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)r*NcCs*d|vri|d<|�|�||_i|_dS�N�auths)�update�_credstore_env�_stores)�self�dctrrrr�__init__Ls


zAuthConfig.__init__FcCs�i}|��D]g\}}t|t�s&t�d|�d��|r"t�d|����iSd|vr;t�d|���d|di||<qd|vrMt�d|�d	��i||<qt|d�\}}t�d
|�d|�d��|||�d
�|d�||<q|S)a 
        Parses authentication entries

        Args:
          entries:        Dict of authentication entries.
          raise_on_error: If set to true, an invalid format will raise
                          InvalidConfigFile

        Returns:
          Authentication registry.
        zConfig entry for key z is not auth configz#Invalid configuration for registry �
identitytokenz*Found an IdentityToken entry for registry �
IdentityToken�authzAuth data for z> is absent. Client might be using a credentials store instead.zFound entry (registry=z, username=r�email��username�passwordr8�
serveraddress)	�itemsr)�dictrrr�InvalidConfigFile�decode_auth�get)�cls�entries�raise_on_error�confr�entryr:r;rrr�
parse_authSs@

���
���zAuthConfig.parse_authc
CsH|sKt�|�}|s|i|�Szt|��
}t�|�}Wd�n1s#wYWn!tttfyJ}zt�	|�|t
|�|�WYd}~Sd}~wwi}|�d�rft�	d�|�d|j
|�d�dd�i�|�d�rzt�	d�|�d|�d�i�|�d�r�t�	d	�|�d|�d�i�|r�|||�St�	d
�|d|�
|�i|�S)a8
        Loads authentication data from a Docker configuration file in the given
        root directory or if config_path is passed use given path.
        Lookup priority:
            explicit config_path parameter > DOCKER_CONFIG environment
            variable > ~/.docker/config.json > ~/.dockercfg
        Nr.zFound 'auths' sectionT)rD�
credsStorezFound 'credsStore' section�credHelperszFound 'credHelpers' sectionzNCouldn't find auth-related section ; attempting to interpret as auth-only file)r�find_config_file�open�json�load�OSError�KeyError�
ValueErrorrr�_load_legacy_configrAr/rG�pop)rB�config_path�config_dictr�config_file�f�e�resrrrr�sD



��
��


��




�zAuthConfig.load_configcC�|�di�Sr-�rA�r2rrrr.��zAuthConfig.authscCs|�dd�S)NrHrZr[rrr�creds_store�r\zAuthConfig.creds_storecCrY)NrIrZr[rrr�cred_helpers�r\zAuthConfig.cred_helperscCs|jo|jo|jSr()r.r]r^r[rrrr�s�zAuthConfig.is_emptycCs�|js|jr)|�|�}|dur)t�d|�d��|�||�}|dur$|St�d�|r/t|�nt}t�dt|����||j	vrOt�dt|����|j	|S|j	�
�D]\}}t|�|krlt�dt|����|SqTt�d�dS)a+
        Returns the authentication data from the given auth configuration for a
        specific registry. As with the Docker client, legacy entries in the
        config with full URLs are stripped down to hostnames before checking
        for a match. Returns None if no match was found.
        NzUsing credentials store "�"z/No entry in credstore - fetching from auth dict�Looking for auth entry for zFound �No entry found)r]r^r+rr�_resolve_authconfig_credstorerr�reprr.r=)r2r�
store_name�cfg�keyrErrrr�s,

�


�
zAuthConfig.resolve_authconfigc
Cs�|r|tkrt}t�dt|����|�|�}z'|�|�}d|i}|dtkr0|d|d<|WS|�|d|dd��|WSt	j
yNt�d�YdSt	jye}zt�
dt|����|�d}~ww)	Nr`�
ServerAddress�Username�Secretr6)rh�PasswordrazCredentials store error: )r�	INDEX_URLrrrc�_get_store_instancerA�TOKEN_USERNAMEr/r�CredentialsNotFound�
StoreErrorr�DockerException)r2r�credstore_name�store�datarXrWrrrrb�s6

���
����z(AuthConfig._resolve_authconfig_credstorecCs*||jvrtj||jd�|j|<|j|S)N)�environment)r1r�Storer0)r2�namerrrrls

�
zAuthConfig._get_store_instancecCs"|r|tkrt}|j�|�p|jSr()rrkr^rAr])r2rrrrr+szAuthConfig.get_credential_storecCs�|j��}|jr(|�|j�}|����D]}|�||j�||<|||t|�<q|j�	�D]\}}|�||�||<|||t|�<q-|Sr()
r.�copyr]rl�list�keysrbrr^r=)r2�	auth_datarr�k�regrdrrr�get_all_credentialss
��zAuthConfig.get_all_credentialscCs||d|<dSr-r)r2r|rsrrr�add_auth1szAuthConfig.add_authr(�F)�__name__�
__module__�__qualname__r4�classmethodrGr�propertyr.r]r^rrrbrlr+r}r~rrrrr*Ks(
;/




#r*cCst|t�s
t||�}|�|�Sr()r)r*r)r,rrrrrr5s


rcCs |�dd��dd��dd�dS)Nzhttp://�zhttps://r rr)�replacer$)�urlrrrr;s rcCsBt|t�r
|�d�}t�|�}|�dd�\}}|�d�|�d�fS)N�ascii�:r�utf8)r)�str�encode�base64�	b64decoder$�decode)r7�s�login�pwdrrrr@?s



r@cCst�|��d�}t�|�S)Nr�)rL�dumpsr�r��urlsafe_b64encode)r7�	auth_jsonrrrrGs
rFcCst�||�S)a
    Parses authentication entries

    Args:
      entries:        Dict of authentication entries.
      raise_on_error: If set to true, an invalid format will raise
                      InvalidConfigFile

    Returns:
      Authentication registry.
    )r*rG)rCrDrrrrGLs
rGcCst�|||�Sr()r*r)rSrTrrrrr\src
Cs�t�d�zJg}t|��&}|��D]}|�|���d�d�qt|�dkr+t�	d��Wd�n1s5wYt
|d�\}}dt|||dtd�iiWSt
yf}zt�|�WYd}~nd}~wwt�d	�iS)
Nz+Attempting to parse legacy auth file formatz = r�z$Invalid or empty configuration file!rr.r9z4All parsing attempts failed - returning empty config)rrrK�	readlines�append�stripr$r%rr?r@rrk�	Exception)rUrsrV�liner:r;rWrrrrQ`s6

���	����
rQ)NNr)NNN)r�rL�loggingr�rr�utilsrrrkrm�	getLoggerr�rrrrr
r+r>r*rrr@rrGrrQrrrr�<module>s.


k