403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.216.71.122
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/paste/auth/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/paste/auth/__pycache__/digest.cpython-37.pyc
B

���]�"�@s�dZddlmZddlTyddlmZWn ek
rHddlmZYnXddlZddlZddl	m
Zdd�Zd	d
�Z
dd�ZGd
d�de�ZGdd�de�ZeZddgZdd�Zdekr�ddlZejejd�dS)a
Digest HTTP/1.1 Authentication

This module implements ``Digest`` authentication as described by
RFC 2617 [1]_ .

Basically, you just put this module before your application, and it
takes care of requesting and handling authentication requests.  This
module has been tested with several common browsers "out-in-the-wild".

>>> from paste.wsgilib import dump_environ
>>> from paste.httpserver import serve
>>> # from paste.auth.digest import digest_password, AuthDigestHandler
>>> realm = 'Test Realm'
>>> def authfunc(environ, realm, username):
...     return digest_password(realm, username, username)
>>> serve(AuthDigestHandler(dump_environ, realm, authfunc))
serving on...

This code has not been audited by a security expert, please use with
caution (or better yet, report security holes). At this time, this
implementation does not provide for further challenges, nor does it
support Authentication-Info header.  It also uses md5, and an option
to use sha would be a good thing.

.. [1] http://www.faqs.org/rfcs/rfc2617.html
�)�HTTPUnauthorized)�*)�md5N)�quotec	cs�d}xj|�d�D]\}y |�d�dkr2d||f}wWn(tk
r\|dkrT|}wnt�YnX|��V|}qW|��Vt�dS)z> split a digest auth string into individual key=value strings N�,�"�z%s,%s)�split�count�AttributeError�
StopIteration�strip)�auth_string�prev�item�r�B/opt/alt/python37/lib/python3.7/site-packages/paste/auth/digest.py�_split_auth_string)s


rccs\xVt|�D]J}|�dd�\}}|�d�rJt|�dkrJ|�d�rJ|dd�}||fVq
WdS)z2 split a digest auth string into key, value pairs �=rr���N)rr	�
startswith�len�endswith)rr�k�vrrr�_auth_to_kv_pairs=s
 rcCstd|||f���S)z; construct the appropriate hashcode needed for HTTP digest z%s:%s:%s)r�	hexdigest)�realm�username�passwordrrr�digest_passwordEsr c@s6eZdZdZdd�Zddd�Zdd�Zd	d
�ZeZdS)
�AuthDigestAuthenticatorz9 implementation of RFC 2617 - HTTP Digest Authentication cCsi|_||_||_dS)N)�nonce�authfuncr)�selfrr#rrr�__init__Ksz AuthDigestAuthenticator.__init__�cCs�tdt��t��f���}tdt��t��f���}d|j|<|jd||d�}|r^d|d<d�dd	�|��D��}d
d|fg}t|d�S)
z! builds the authentication error z%s:%sN�auth)r�qopr"�opaque�true�stalez, cSsg|]\}}d||f�qS)z%s="%s"r)�.0rrrrr�
<listcomp>[sz@AuthDigestAuthenticator.build_authentication.<locals>.<listcomp>zWWW-Authenticatez	Digest %s)�headers)	r�time�randomrr"r�join�itemsr)r$r+r"r)�parts�headrrr�build_authenticationPs

z,AuthDigestAuthenticator.build_authenticationc

Cs�|s|��Std||f���}
|	r:d|||||	|
f}nd|||
f}|t|���krr||jkrj|j|=|��S|j�|d�}||kr�||jkr�|j|=|jdd�S||j|<|S)z; computes the authentication, raises error if unsuccessful z%s:%sz%s:%s:%s:%s:%s:%sz%s:%s:%s�00000000T)r+)r5rrr"�get)
r$�ha1r�response�method�pathr"�nc�cnoncer(Zha2ZchkZpncrrr�compute_s"


zAuthDigestAuthenticator.computecCs.t|�}tt|��tt|��}t|�}|s4|��S|�dd�\}}d|��krX|��Stt	|��}y�|d}|d}	|d}
|d}|d}|	�d	d�d
|ks�t
�||jks�t
�|�dd�}
|�d
d�}|�dd�}|
r�d|
ks�t
�|
r�|s�t
�Wn|��S|�
|||�}|�|||||	|
|||
�	S)z� This function takes a WSGI environment and authenticates
            the request returning authenticated user or error.
        � r�digestrZurir"rr9�?rr(r&r=r<r6r')ZREQUEST_METHOD�	url_quoteZSCRIPT_NAMEZ	PATH_INFOZ
AUTHORIZATIONr5r	�lower�dictr�AssertionErrorrr7r#r>)r$�environr:�fullpathZ
authorizationZauthmethr'ZamaprZauthpathr"rr9r(r=r<r8rrr�authenticateus8z$AuthDigestAuthenticator.authenticateN)r&)	�__name__�
__module__�__qualname__�__doc__r%r5r>rH�__call__rrrrr!Is
!r!c@s eZdZdZdd�Zdd�ZdS)�AuthDigestHandlera
    middleware for HTTP Digest authentication (RFC 2617)

    This component follows the procedure below:

        0. If the REMOTE_USER environment variable is already populated;
           then this middleware is a no-op, and the request is passed
           along to the application.

        1. If the HTTP_AUTHORIZATION header was not provided or specifies
           an algorithem other than ``digest``, then a HTTPUnauthorized
           response is generated with the challenge.

        2. If the response is malformed or or if the user's credientials
           do not pass muster, another HTTPUnauthorized is raised.

        3. If all goes well, and the user's credintials pass; then
           REMOTE_USER environment variable is filled in and the
           AUTH_TYPE is listed as 'digest'.

    Parameters:

        ``application``

            The application object is called only upon successful
            authentication, and can assume ``environ['REMOTE_USER']``
            is set.  If the ``REMOTE_USER`` is already set, this
            middleware is simply pass-through.

        ``realm``

            This is a identifier for the authority that is requesting
            authorization.  It is shown to the user and should be unique
            within the domain it is being used.

        ``authfunc``

            This is a callback function which performs the actual
            authentication; the signature of this callback is:

              authfunc(environ, realm, username) -> hashcode

            This module provides a 'digest_password' helper function
            which can help construct the hashcode; it is recommended
            that the hashcode is stored in a database, not the user's
            actual password (since you only need the hashcode).
    cCst||�|_||_dS)N)r!rH�application)r$rOrr#rrrr%�szAuthDigestHandler.__init__cCsRt|�}|sF|�|�}t|t�r:t�|d�t�||�n|�||�S|�||�S)Nr@)ZREMOTE_USERrH�
isinstance�strZ	AUTH_TYPE�updateZwsgi_applicationrO)r$rFZstart_responser�resultrrrrM�s

zAuthDigestHandler.__call__N)rIrJrKrLr%rMrrrrrN�s/rNcKs<ddlm}ddl}||�}t||j�s0td��t|||�S)z�
    Grant access via digest authentication

    Config looks like this::

      [filter:grant]
      use = egg:Paste#auth_digest
      realm=myrealm
      authfunc=somepackage.somemodule:somefunction

    r)�eval_importNz#authfunc must resolve to a function)Zpaste.util.import_stringrT�typesrP�FunctionTyperErN)ZappZglobal_confrr#�kwrTrUrrr�make_digest�s
rX�__main__)Zoptionflags)rLZpaste.httpexceptionsrZpaste.httpheaders�hashlibr�ImportErrorr/r0�urllibrrBrrr �objectr!rNZ
middleware�__all__rXrIZdoctestZtestmod�ELLIPSISrrrr�<module>s&O?

Youez - 2016 - github.com/yon3zu
LinuXploit