
    Gd>                    H   d dl mZ d dlZd dlZd dlZd dlZd dlmZ ddl	m
Z
 ddl	mZ ddl	mZ ddl	mZ d	d
lmZ d	dlmZ ej        rd dlZ G d d          ZdddZ G d d          Zd ZdD ]1Z e eee                    Z eeee            eeee           2dS )    )annotationsNwraps   )dump_header)parse_dict_header)parse_set_header)quote_header_value   )CallbackDict)	HeaderSetc                  z    e Zd ZdZ	 	 dddZddZddZd d!dZd"dZd#dZ	e
d$d            Zd%dZd%dZd%dZdS )&Authorizationa  Represents the parts of an ``Authorization`` request header.

    :attr:`.Request.authorization` returns an instance if the header is set.

    An instance can be used with the test :class:`.Client` request methods' ``auth``
    parameter to send the header in test requests.

    Depending on the auth scheme, either :attr:`parameters` or :attr:`token` will be
    set. The ``Basic`` scheme's token is decoded into the ``username`` and ``password``
    parameters.

    For convenience, ``auth["key"]`` and ``auth.key`` both access the key in the
    :attr:`parameters` dict, along with ``auth.get("key")`` and ``"key" in auth``.

    .. versionchanged:: 2.3
        The ``token`` parameter and attribute was added to support auth schemes that use
        a token instead of parameters, such as ``Bearer``.

    .. versionchanged:: 2.3
        The object is no longer a ``dict``.

    .. versionchanged:: 0.5
        The object is an immutable dict.
    N	auth_typestrdatadict[str, str] | Nonetoken
str | NonereturnNonec                <    || _         	 |i }|| _        	 || _        d S N)type
parametersr   )selfr   r   r   s       X/var/www/html/t/fyr/venv311/lib/python3.11/site-packages/werkzeug/datastructures/auth.py__init__zAuthorization.__init__.   s7     	R<D	 
	 	    namec                6    | j                             |          S r   r   getr   r    s     r   __getattr__zAuthorization.__getattr__F       ""4(((r   c                6    | j                             |          S r   r"   r$   s     r   __getitem__zAuthorization.__getitem__I   r&   r   keydefaultc                8    | j                             ||          S r   r"   r   r)   r*   s      r   r#   zAuthorization.getL       ""3000r   boolc                    || j         v S r   r   r   r)   s     r   __contains__zAuthorization.__contains__O       do%%r   otherobjectc                    t          |t                    st          S |j        | j        k    o|j        | j        k    o|j        | j        k    S r   )
isinstancer   NotImplementedr   r   r   r   r4   s     r   __eq__zAuthorization.__eq__R   sP    %// 	"!! J$)# 4tz)4 DO3	
r   valuete.Self | Nonec                   |sdS |                     d          \  }}}|                                }|                                }|dk    rk	 t          j        |                                                               d          \  }}}n# t          j        t          f$ r Y dS w xY w | |||d          S d|	                    d          v r | |t          |          d          S  | |d|          S )zParse an ``Authorization`` header value and return an instance, or ``None``
        if the value is empty.

        :param value: The header value to parse.

        .. versionadded:: 2.3
        N basic:)usernamepassword=)	partitionlowerstripbase64	b64decodedecodebinasciiErrorUnicodeErrorrstripr   )clsr;   scheme_restrA   rB   s          r   from_headerzAuthorization.from_header\   s     	4//#..4zz||W(.(8(>(>(E(E(G(G(Q(QRU(V(V%!XXNL1   tt 3vH(KKLLL$++c""""3v066=== s64&&&s   =B B%$B%c                f   | j         dk    rMt          j        | j         d| j                                                                       d          }d| S | j        #| j                                          d| j         S | j                                          dt          | j
                   S )ziProduce an ``Authorization`` header value representing this data.

        .. versionadded:: 2.0
        r?   r@   utf8zBasic Nr>   )r   rG   	b64encoderA   rB   encoderI   r   titler   r   r   r;   s     r   	to_headerzAuthorization.to_header{   s    
 9$=224=2299;; fVnn  $E###:!ioo''66$*666)//##DDk$/&B&BDDDr   c                *    |                                  S r   rY   r   s    r   __str__zAuthorization.__str__       ~~r   c                \    dt          |           j         d|                                  dS N<r>   >r   __name__rY   r\   s    r   __repr__zAuthorization.__repr__   .    <4::&<<)9)9<<<<r   )NN)r   r   r   r   r   r   r   r   r    r   r   r   r   r)   r   r*   r   r   r   r)   r   r   r.   r4   r5   r   r.   r;   r   r   r<   r   r   )rd   
__module____qualname____doc__r   r%   r(   r#   r2   r:   classmethodrR   rY   r]   re    r   r   r   r      s        8 '+ 	    0) ) ) )) ) ) )1 1 1 1 1& & & &
 
 
 
 ' ' ' ['<E E E E        = = = = = =r   r   r    r   docr   r   propertyc                p     t          j        dt          d            fd}t           fd||          S )a*  A static helper function for Authentication subclasses to add
    extra authentication system properties onto a class::

        class FooAuthenticate(WWWAuthenticate):
            special_realm = auth_property('special_realm')

    .. deprecated:: 2.3
        Will be removed in Werkzeug 3.0.
    zB'auth_property' is deprecated and will be removed in Werkzeug 3.0.r   
stacklevelc                `    ||                      d            d S t          |          | <   d S r   )popr   )r   r;   r    s     r   
_set_valuez!auth_property.<locals>._set_value   s5    =HHT4     UDJJJr   c                .    |                                S r   )r#   )xr    s    r   <lambda>zauth_property.<locals>.<lambda>   s    aeeDkk r   )rr   )warningswarnDeprecationWarningrs   )r    rr   ry   s   `  r   auth_propertyr      sa     ML   $ $ $ $ $ )))):3????r   c                      e Zd ZdZ	 	 	 d;d<dZd=dZed>d            Zej        d?d            Zed@d            Z	e	j        dAd            Z	edBd            Z
e
j        dCd            Z
dDdEdZ	 	 	 	 dFdGd!ZdHd#ZdId$ZdJd%ZdKd'ZdL fd(ZdMd)ZdNd*ZdOd-ZdPdQd/ZedRd1            Zd>d2Zd>d3Zd>d4ZedSd6            ZedTd8            Zej        dUd:            Z ee          Z xZS )VWWWAuthenticatea  Represents the parts of a ``WWW-Authenticate`` response header.

    Set :attr:`.Response.www_authenticate` to an instance of list of instances to set
    values for this header in the response. Modifying this instance will modify the
    header value.

    Depending on the auth scheme, either :attr:`parameters` or :attr:`token` should be
    set. The ``Basic`` scheme will encode ``username`` and ``password`` parameters to a
    token.

    For convenience, ``auth["key"]`` and ``auth.key`` both act on the :attr:`parameters`
    dict, and can be used to get, set, or delete parameters. ``auth.get("key")`` and
    ``"key" in auth`` are also provided.

    .. versionchanged:: 2.3
        The ``token`` parameter and attribute was added to support auth schemes that use
        a token instead of parameters, such as ``Bearer``.

    .. versionchanged:: 2.3
        The object is no longer a ``dict``.

    .. versionchanged:: 2.3
        The ``on_update`` parameter was removed.
    Nr   r   valuesr   r   c                     |t          j        dt          d           d}|                                 _        t          | fd           _        | _        d  _        d S )NzvAn auth type must be given as the first parameter. Assuming 'basic' is deprecated and will be removed in Werkzeug 3.0.r   ru   r?   c                ,                                     S r   _trigger_on_updaterP   r   s    r   r|   z*WWWAuthenticate.__init__.<locals>.<lambda>   s    d5577 r   )	r}   r~   r   rE   _typer   _parameters_token
_on_update)r   r   r   r   s   `   r   r   zWWWAuthenticate.__init__   s}     MC"	     I__&&
+77777,
 ,
 FJr   r   r   c                B    | j         |                      |            d S d S r   )r   r\   s    r   r   z"WWWAuthenticate._trigger_on_update   s*    ?&OOD!!!!! '&r   r   c                    | j         S )zDThe authorization scheme, like ``Basic``, ``Digest``, or ``Bearer``.)r   r\   s    r   r   zWWWAuthenticate.type   s     zr   r;   c                <    || _         |                                  d S r   )r   r   rX   s     r   r   zWWWAuthenticate.type   s!    
!!!!!r   dict[str, str]c                    | j         S z~A dict of parameters for the header. Only one of this or :attr:`token` should
        have a value for a give scheme.
        )r   r\   s    r   r   zWWWAuthenticate.parameters   s    
 r   c                `     t          | fd           _                                          d S )Nc                ,                                     S r   r   r   s    r   r|   z,WWWAuthenticate.parameters.<locals>.<lambda>   s    T4466 r   )r   r   r   rX   s   ` r   r   zWWWAuthenticate.parameters   s>    '6666
 
 	!!!!!r   c                    | j         S r   )r   r\   s    r   r   zWWWAuthenticate.token   s    
 {r   c                <    || _         |                                  dS )zA token for the header. Only one of this or :attr:`parameters` should have a
        value for a given scheme.

        .. versionadded:: 2.3
        N)r   r   rX   s     r   r   zWWWAuthenticate.token   s#     !!!!!r   authentication requiredrealmc                    t          j        d           d| _        t                              | j                   t                              | j        d|i           d| _        |                                  dS )zClear any existing data and set a ``Basic`` challenge.

        .. deprecated:: 2.3
            Will be removed in Werkzeug 3.0. Create and assign an instance instead.
        zpThe 'set_basic' method is deprecated and will be removed in Werkzeug 3.0. Create and assign an instance instead.r?   r   N)	r}   r~   r   dictclearr   updater   r   )r   r   s     r   	set_basiczWWWAuthenticate.set_basic  s~     	6	
 	
 	
 


4?###Oe	
 	
 	
 !!!!!r   authFnonceqopt.Sequence[str]opaque	algorithmstaler.   c                H   t          j        d           d| _        t                              | j                   ||d                    |          |rdndd}|||d<   |||d	<   t                              | j        |           d| _        | 	                                 dS )
zClear any existing data and set a ``Digest`` challenge.

        .. deprecated:: 2.3
            Will be removed in Werkzeug 3.0. Create and assign an instance instead.
        zqThe 'set_digest' method is deprecated and will be removed in Werkzeug 3.0. Create and assign an instance instead.digest, TRUEFALSE)r   r   r   r   Nr   r   )
r}   r~   r   r   r   r   joinr   r   r   )r   r   r   r   r   r   r   r   s           r   
set_digestzWWWAuthenticate.set_digest  s     	6	
 	
 	
 


4?###99S>>$1VV'	
 

 #)Jx  &/J{#DOZ000!!!!!r   r)   c                6    | j                             |          S r   r"   r1   s     r   r(   zWWWAuthenticate.__getitem__@  s    ""3'''r   c                j    ||| j         v r| j         |= n
|| j         |<   |                                  d S r   r   r   )r   r)   r;   s      r   __setitem__zWWWAuthenticate.__setitem__C  sC    =do%%OC(#(DOC !!!!!r   c                T    || j         v r| j         |= |                                  d S d S r   r   r1   s     r   __delitem__zWWWAuthenticate.__delitem__L  s9    $/!!$##%%%%% "!r   r    c                    | |         S r   rq   r$   s     r   r%   zWWWAuthenticate.__getattr__Q  s    Dzr   c                b    |dv r$t                                          ||           d S || |<   d S )N>   r   r   r   r   )super__setattr__)r   r    r;   	__class__s      r   r   zWWWAuthenticate.__setattr__T  s<    CCCGGe,,,,,DJJJr   c                    | |= d S r   rq   r$   s     r   __delattr__zWWWAuthenticate.__delattr__Z  s    JJJr   c                    || j         v S r   r0   r1   s     r   r2   zWWWAuthenticate.__contains__]  r3   r   r4   r5   c                    t          |t                    st          S |j        | j        k    o|j        | j        k    o|j        | j        k    S r   )r7   r   r8   r   r   r   r9   s     r   r:   zWWWAuthenticate.__eq__`  sP    %11 	"!! J$)# 4tz)4 DO3	
r   r*   c                8    | j                             ||          S r   r"   r,   s      r   r#   zWWWAuthenticate.getj  r-   r   r<   c                   |sdS |                     d          \  }}}|                                }|                                }d|                    d          v r | |t	          |          d          S  | |d|          S )zParse a ``WWW-Authenticate`` header value and return an instance, or ``None``
        if the value is empty.

        :param value: The header value to parse.

        .. versionadded:: 2.3
        Nr>   rC   )rD   rE   rF   rM   r   )rN   r;   rO   rP   rQ   s        r   rR   zWWWAuthenticate.from_headerm  s      	4//#..4zz||$++c""""3v066=== s64&&&r   c                   | j         #| j                                         d| j          S | j        dk    rxg }| j                                        D ]D\  }}|dv rt          |d          }nt          |          }|                    | d|            Edd	                    |           S | j                                         dt          | j                   S )
zCProduce a ``WWW-Authenticate`` header value representing this data.Nr>   r   >   r   r   r   domainr   F)allow_tokenrC   zDigest r   )	r   r   rW   r   itemsr
   appendr   r   )r   r   r)   r;   s       r   rY   zWWWAuthenticate.to_header  s    :!ioo''66$*6669  E"o3355 / /
UGGG.u%HHHEE.u55E--e--..../TYYu--///)//##DDk$/&B&BDDDr   c                *    |                                  S r   r[   r\   s    r   r]   zWWWAuthenticate.__str__  r^   r   c                \    dt          |           j         d|                                  dS r`   rc   r\   s    r   re   zWWWAuthenticate.__repr__  rf   r   set[str]c                     t          j        dt          d           d
 fd}t           j                            d	          |          S )zThe ``qop`` parameter as a set.

        .. deprecated:: 2.3
            Will be removed in Werkzeug 3.0. It will become the same as other
            parameters, returning a string.
        zThe 'qop' property is deprecated and will be removed in Werkzeug 3.0. It will become the same as other parameters, returning a string.r   ru   r;   r   r   r   c                V    | s	dv rd= d S |                                  j        d<   d S )Nr   )rY   r   )r;   r   s    r   	on_updatez&WWWAuthenticate.qop.<locals>.on_update  s<     D==U%*__%6%6DOE"""r   r   )r;   r   r   r   )r}   r~   r   r	   r   r#   )r   r   s   ` r   r   zWWWAuthenticate.qop  sj     	P		
 	
 	
 	
	7 	7 	7 	7 	7 	7   3 3E : :IFFFr   bool | Nonec                    t          j        dt          d           d| j        v r#| j        d                                         dk    S dS )zThe ``stale`` parameter as a boolean.

        .. deprecated:: 2.3
            Will be removed in Werkzeug 3.0. It will become the same as other
            parameters, returning a string.
        zThe 'stale' property is deprecated and will be removed in Werkzeug 3.0. It will become the same as other parameters, returning a string.r   ru   r   trueN)r}   r~   r   r   rE   r\   s    r   r   zWWWAuthenticate.stale  s[     	P		
 	
 	
 	
 do%%?7+1133v==tr   bool | str | Nonec                    |d| j         v r| j         d= d S t          |t                    r,t          j        dt
          d           |rdnd| j         d<   d S || j         d<   d S )Nr   z\Setting the 'stale' property to a boolean is deprecated and will be removed in Werkzeug 3.0.r   ru   r   r   )r   r7   r.   r}   r~   r   rX   s     r   r   zWWWAuthenticate.stale  s    =$/))OG,FeT"" 		-M,"	    27'CvvGDOG$$$',DOG$$$r   )NNN)r   r   r   r   r   r   )r   r   rl   )r;   r   r   r   )r   r   )r;   r   r   r   )r   r   )r;   r   r   r   )r   )r   r   r   r   )r   NNF)r   r   r   r   r   r   r   r   r   r   r   r.   r   r   )r)   r   r   r   )r)   r   r;   r   r   r   )r)   r   r   r   rg   )r    r   r;   r   r   r   )r    r   r   r   ri   rj   r   rh   rk   )r   r   )r   r   )r;   r   r   r   ) rd   rm   rn   ro   r   r   rs   r   setterr   r   r   r   r(   r   r   r%   r   r   r2   r:   r#   rp   rR   rY   r]   re   r   r   staticmethodr   __classcell__)r   s   @r   r   r      s        6 !%(, 	K K K K K," " " "    X 
[" " " ["       X  " " " "    X \" " " \"" " " " ".  )! $#" #" #" #" #"J( ( ( (" " " "& & & &
           & & & &
 
 
 
1 1 1 1 1 ' ' ' [',E E E E(       = = = = G G G XG2    X& \- - - \-$ !L//MMMMMr   r   c                <     t                      fd            }|S )Nc                 L    t          j        dt          d            | i |S )NzTreating 'Authorization' and 'WWWAuthenticate' as a dict is deprecated and will be removed in Werkzeug 3.0. Use the 'parameters' attribute instead.r   ru   )r}   r~   r   )argskwargsfs     r   wrapperz(_deprecated_dict_method.<locals>.wrapper  s?    X		
 	
 	
 	
 q$!&!!!r   r   )r   r   s   ` r   _deprecated_dict_methodr     s3    
1XX" " " " X" Nr   )
__iter__r   copyr   keysrx   popitem
setdefaultr   r   r   )r    r   rr   r   r   rs   )
__future__r   rG   rJ   typingtr}   	functoolsr   httpr   r   r	   r
   
structuresr   r   TYPE_CHECKINGtyping_extensionster   r   r   r   r    getattrr   r   setattrrq   r   r   <module>r      s   " " " " " "                    $ $ $ $ $ $ # # # # # # % % % % % % $ $ $ $ $ $ ! ! ! ! ! !? #""""{= {= {= {= {= {= {= {=|@ @ @ @ @2t0 t0 t0 t0 t0 t0 t0 t0n	   & &D 	 d 3 344AGM4###GOT1%%%%& &r   