;iG'ddlmZddlZddlZddlmZddlZddl m Z ddl m Z ddl m Z ddl mZejrddlZGd d ZGd d ZdS) ) annotationsN) dump_header)parse_dict_header)quote_header_value) CallbackDictczeZdZdZ ddd Zdd ZddZd d!dZd"dZd#dZ e d$dZ d%dZ d%dZ d%dZdS)& AuthorizationaRepresents 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_typestrdatadict[str, str | None] | Nonetoken str | NonereturnNonec<||_ |i}||_ ||_dSN)type parametersr)selfr rrs PC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\werkzeug/datastructures/auth.py__init__zAuthorization.__init__+s7  R <D    namec6|j|Srrgetrrs r __getattr__zAuthorization.__getattr__C""4(((rc6|j|Srrr s r __getitem__zAuthorization.__getitem__Fr"rkeydefaultc8|j||Srrrr%r&s rrzAuthorization.getI""3000rboolc||jvSrrrr%s r __contains__zAuthorization.__contains__Ldo%%rotherobjectct|tstS|j|jko|j|jko|j|jkSr) isinstancer NotImplementedrrrrr0s r__eq__zAuthorization.__eq__OsP%// "! ! J$) # 4 tz) 4 DO3 rvaluete.Self | Nonec|sdS|d\}}}|}|}|dkrk tj|d\}}}n#t jtf$rYdSwxYw||||dSd| dvr||t|dS||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:)usernamepassword=) partitionlowerstripbase64 b64decodedecodebinasciiError UnicodeErrorrstripr)clsr7scheme_restr=r>s r from_headerzAuthorization.from_headerYs 4//#..4zz|| W   (.(8(>(>(E(E(G(G(Q(QRU(V(V%!XXNL1   tt 3vH(KKLL L $++c"" " "3v066== =s64&&&s =B B%$B%cf|jdkrMtj|jd|jd}d|S|j#|jd|jS|jdt|j S)ziProduce an ``Authorization`` header value representing this data. .. versionadded:: 2.0 r;r<asciizBasic Nr:) rrC b64encoder=r>encoderErtitlerrrr7s r to_headerzAuthorization.to_headerxs 9  $=224=2299;;fWoo $E## # : !ioo''66$*66 6)//##DDk$/&B&BDDDrc*|SrrUrs r__str__zAuthorization.__str__~~rc\dt|jd|dSNr__name__rUrXs r__repr__zAuthorization.__repr__.<4::&<<)9)9<<<WWWAuthenticateaRepresents 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 valuesrrrc|_t|fd_|_d_dS)Nc,Sr_trigger_on_updaterLrs rz*WWWAuthenticate.__init__..sd5577r)rA_typer _parameters_token _on_update)rr rqrs` rrzWWWAuthenticate.__init__sK __&& 2> 77773 3  IMrrrcB|j||dSdSr)r{rXs rruz"WWWAuthenticate._trigger_on_updates* ? & OOD ! ! ! ! ! ' &rc|jS)zDThe authorization scheme, like ``basic``, ``digest``, or ``bearer``.)rxrXs rrzWWWAuthenticate.types zrr7c<||_|dSr)rxrurTs rrzWWWAuthenticate.types!  !!!!!rdict[str, str | None]c|jSzA dict of parameters for the header. Only one of this or :attr:`token` should have a value for a given scheme. )ryrXs rrzWWWAuthenticate.parameterss rdict[str, str]c`t|fd_dS)Nc,Srrtrvs rrwz,WWWAuthenticate.parameters..s9P9P9R9Rr)r ryrurTs` rrzWWWAuthenticate.parameterss7'/R/R/R/RSS !!!!!rc|jSr)rzrXs rrzWWWAuthenticate.tokens {rc<||_|dS)zA token for the header. Only one of this or :attr:`parameters` should have a value for a given scheme. .. versionadded:: 2.3 N)rzrurTs rrzWWWAuthenticate.tokens#  !!!!!rr%c6|j|Srrr-s rr$zWWWAuthenticate.__getitem__s""3'''rcj|||jvr|j|=n ||j|<|dSrrru)rr%r7s r __setitem__zWWWAuthenticate.__setitem__sC =do%%OC(#(DOC  !!!!!rcT||jvr|j|=|dSdSrrr-s r __delitem__zWWWAuthenticate.__delitem__s9 $/ ! !$  # # % % % % % " !rrc||Srrnr s rr!zWWWAuthenticate.__getattr__s Dzrcb|dvr$t||dS|||<dS)N>rxrzr{ry)super __setattr__)rrr7 __class__s rrzWWWAuthenticate.__setattr__s< C C C GG  e , , , , ,DJJJrc ||=dSrrnr s r __delattr__zWWWAuthenticate.__delattr__s JJJrr*c||jvSrr,r-s rr.zWWWAuthenticate.__contains__r/rr0r1ct|tstS|j|jko|j|jko|j|jkSr)r3rpr4rrrr5s rr6zWWWAuthenticate.__eq__sP%11 "! ! J$) # 4 tz) 4 DO3 rr&c8|j||Srrr(s rrzWWWAuthenticate.get r)rr8c|sdS|d\}}}|}|}d|dvr||t |dS||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:r?)r@rArBrIr)rJr7rKrLrMs rrNzWWWAuthenticate.from_headers 4//#..4zz|| $++c"" " "3v066== =s64&&&rc|j#|jd|jS|jdkrxg}|jD]D\}}|dvrt |d}nt |}||d|Edd |S|jdt|jS) zCProduce a ``WWW-Authenticate`` header value representing this data.Nr:digest>qopnoncerealmdomainopaqueF) allow_tokenr?zDigest z, ) rrrSritemsrappendjoinr)rrr%r7s rrUzWWWAuthenticate.to_header%s : !ioo''66$*66 6 9 E"o3355 / / UGGG.u%HHHEE.u55E --e--..../TYYu--// /)//##DDk$/&B&BDDDrc*|SrrWrXs rrYzWWWAuthenticate.__str__9rZrc\dt|jd|dSr\r_rXs rrazWWWAuthenticate.__repr__<rbrrc)r r rqrrr)rrri)r7r rr)rr)r7rrr)rr)r7rrr)r%r rr)r%r r7rrr)r%r rrrd)rr r7rrr)rr rrrfrgrrerh)r`rjrkrlrrupropertyrsetterrrr$rrr!rrr.r6rrmrNrUrYra __classcell__)rs@rrprpsN804 N N N N N""""X ["""["   X """"X  \"""\"((((""""&&&&  &&&&    11111'''[',EEEE(    ========rrp) __future__rrCrFcollections.abcabccabctypingthttprrr structuresr TYPE_CHECKINGtyping_extensionster rprnrrrs"""""" $$$$$$%%%%%%$$$$$$?#""""{={={={={={={={=|n=n=n=n=n=n=n=n=n=n=r