HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/supervisor/medusa/__pycache__/auth_handler.cpython-36.pyc
3

�k�`~�@s�dZddlZddlZddlZddlmZmZddlmZmZddlm	Z	ddlm
Z
ddljj
Z
ddljjZejZddljjZGdd�d�ZGd	d
�d
�Zejdej�ZdS)z>$Id: auth_handler.py,v 1.6 2002/11/25 19:40:23 akuchling Exp $�N)�	as_string�as_bytes)�encodestring�decodestring)�long)�md5c@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�auth_handler�defaultcCs.t|�|_||_||_tj�|_tj�|_dS)N)�dictionary_authorizer�
authorizer�handler�realm�counter�
pass_count�
fail_count)�self�dictrr
�r�"/usr/lib/python3.6/auth_handler.py�__init__#s


zauth_handler.__init__cCs|jj|�S)N)r�match)r�requestrrrr*szauth_handler.matchc
Cs�tt|j�}|r�|j�}|dkr�tt|jd�}yttt|���}Wn$tjj	d|�|j
d�dS|jdd�}|jj
|�r�|jj�||_|jj|�q�|j|�q�tjj	d|�|j|�n
|j|�dS)NZbasic�z"malformed authorization info <%s>
i��:�z$unknown/unsupported auth method: %s
)�
get_header�
AUTHORIZATION�header�lowerrrr�sys�stderr�write�error�splitr�	authorizer�	increment�	auth_infor�handle_request�handle_unauthorized)rr�schemeZcookieZdecodedr&rrrr'.s(

	zauth_handler.handle_requestcCs:|jj�|jjd�d|d<d|j|d<|jd�dS)N�closeZ
ConnectionzBasic realm="%s"zWWW-Authenticatei�)rr%�channelZset_terminatorr
r")rrrrrr(Rs

z auth_handler.handle_unauthorizedcCs\|jjj}tttj���}|dd�dkr6|dd�}tt|��}dj|||g�}|j|�S)zEA digest-authentication <nonce>, constructed as suggested in RFC 2069rN�Lr���r-)	r+Zserver�ip�strr�time�id�join�
apply_hash)rrr.ZnowZprivate_keyZnoncerrr�
make_nonce[s
zauth_handler.make_noncecCs(t�}|j|�|j�}t|�dd�S)z;Apply MD5 to a string <s>, then wrap it in base64 encoding.Nrr-)r�updateZdigestr)r�s�m�drrrr3es
zauth_handler.apply_hashcCsHtjd|j�g}t|jd�r.|j|jj��|jtjd��tj|�S)NzB<li>Authorization Extension : <b>Unauthorized requests:</b> %s<ul>�statusz</ul>)�	producersZsimple_producerr�hasattrr�appendr9Zcomposite_producer)r�rrrrr9mszauth_handler.statusN)r	)
�__name__�
__module__�__qualname__rrr'r(r4r3r9rrrrr"s
$	
rc@seZdZdd�Zdd�ZdS)r
cCs
||_dS)N)r)rrrrrr}szdictionary_authorizer.__init__cCs,|\}}||jkr$|j||kr$dSdSdS)Nrr)r)rr&ZusernameZpasswordrrrr$�szdictionary_authorizer.authorizeN)r>r?r@rr$rrrrr
|sr
zAuthorization: ([^ ]+) (.*))ZRCS_ID�rerr0Zsupervisor.compatrrrrrrZsupervisor.medusa.counterZmedusarZ!supervisor.medusa.default_handlerZdefault_handlerrZsupervisor.medusa.producersr:rr
�compile�
IGNORECASErrrrr�<module>s Z