Files
cms-website/.deps_siteforge_v812/itsdangerous/__pycache__/serializer.cpython-312.pyc
T

136 lines
15 KiB
Plaintext
Raw Normal View History

Ë
êÅÙjñ<ãó¦—ddlmZddlmZddlZddlZddlm Z ddl
m Z ddl
m Z ddl
mZddl
mZej r8ddlZej&d ej(eefej(eef¬
«Zn#ej&d ej(eef¬ «ZGd „d
ej0e«Z dd„ZGd„dej6e«Zy)é)Ú annotationsNé)Ú
want_bytes)Ú
BadPayload)Ú BadSignature)Ú_make_keys_list)ÚSignerÚ _TSerialized)ÚboundÚdefault)r có—eZdZdd„Zdd„Zy)Ú_PDataSerializercó—y©N©)ÚselfÚpayloads ú[C:\Users\30997\AppData\Local\Temp\pip-target-6g32zz5s\lib\python\itsdangerous/serializer.pyÚloadsz_PDataSerializer.loadss€¸ócó—yrr©rÚobjs rÚdumpsz_PDataSerializer.dumpss€°CrN)rr
Úreturnút.Any)rrrr
)Ú__name__Ú
__module__Ú __qualname__rrrrrrrs
„Û;ô8rrcó@—t|ji«t«S)z5Checks whether a serializer generates text or binary.)Ú
isinstancerÚstr)Ú
serializers rÚis_text_serializerr$#s€ô �j×&Ñ& rÓ*¬CÓ 0Ð0rcó—eZdZUdZeZded<eZded<gZ ded<e
j d dd „«Z e
j d dd
„«Z e
j d ddddd œ dd „«Z e
j d d!d
„«Z e
j d ddddd œ d!d„«Z d d"d„Z e
d#d„«Z d$ d%d„Zd&d„Zd$d'd„Zd$d(d„Zd$d)d„Zd$d*d„Z d$ d+d„Zd$d,d„Z d$ d-d„Z d. d/d„Z d$ d0d„Zy)1Ú
Serializera: A serializer wraps a :class:`~itsdangerous.signer.Signer` to
enable serializing and securely signing data other than bytes. It
can unsign to verify that the data hasn't been changed.
The serializer provides :meth:`dumps` and :meth:`loads`, similar to
:mod:`json`, and by default uses :mod:`json` internally to serialize
the data to bytes.
The secret key should be a random string of ``bytes`` and should not
be saved to code or version control. Different salts should be used
to distinguish signing in different contexts. See :doc:`/concepts`
for information about the security of the secret key and salt.
:param secret_key: The secret key to sign and verify with. Can be a
list of keys, oldest to newest, to support key rotation.
:param salt: Extra key to combine with ``secret_key`` to distinguish
signatures in different contexts.
:param serializer: An object that provides ``dumps`` and ``loads``
methods for serializing data to a string. Defaults to
:attr:`default_serializer`, which defaults to :mod:`json`.
:param serializer_kwargs: Keyword arguments to pass when calling
``serializer.dumps``.
:param signer: A ``Signer`` class to instantiate when signing data.
Defaults to :attr:`default_signer`, which defaults to
:class:`~itsdangerous.signer.Signer`.
:param signer_kwargs: Keyword arguments to pass when instantiating
the ``Signer`` class.
:param fallback_signers: List of signer parameters to try when
unsigning with the default signer fails. Each item can be a dict
of ``signer_kwargs``, a ``Signer`` class, or a tuple of
``(signer, signer_kwargs)``. Defaults to
:attr:`default_fallback_signers`.
.. versionchanged:: 2.0
Added support for key rotation by passing a list to
``secret_key``.
.. versionchanged:: 2.0
Removed the default SHA-512 fallback signer from
``default_fallback_signers``.
.. versionchanged:: 1.1
Added support for ``fallback_signers`` and configured a default
SHA-512 fallback. This fallback is for users who used the yanked
1.0.0 release which defaulted to SHA-512.
.. versionchanged:: 0.14
The ``signer`` and ``signer_kwargs`` parameters were added to
the constructor.
ú_PDataSerializer[t.Any]Údefault_serializerz type[Signer]Údefault_signerzMlist[dict[str, t.Any] | tuple[type[Signer], dict[str, t.Any]] | type[Signer]]Údefault_fallback_signersNcó—yrr©rÚ
secret_keyÚsaltr#Úserializer_kwargsÚsignerÚ
signer_kwargsÚfallback_signerss rÚ__init__zSerializer.__init__mó€ð rcó—yrrr,s rr3zSerializer.__init__}r4r)r/r0r1r2có—yrrr,s rr3zSerializer.__init__�ó€ð rcó—yrrr,s rr3zSerializer.__init__ r4rcó—yrrr,s rr3zSerializer.__init__°r7rcó(—t|«|_|� t|«}||_|€ |j}||_t
|«|_|€ |j}||_|xsi|_ |€t|j«}||_ |xsi|_
yr)rÚ secret_keysrr.r(r#r$r)r0r1Úlistr*r2r/r,s rr3zSerializer.__init__Às§€ô$)8¸
Ó(CˆÔà РܘdÓ#ˆDðˆŒ à Ð Ø×0Ñ0ˆJà:DˆŒÜ(:¸:Ó(FˆÔà ˆ>Ø×(Ñ(ˆFà$*ˆŒ Ø/<Ò/BÀˆÔà Ð #Ü# D×$AÑ$AÓBÐ ð
ð
Ôð4EÒ3JȈÕrcó —|jdS)z�The newest (last) entry in the :attr:`secret_keys` list. This
is for compatibility from before key rotation support was added.
éÿÿÿÿ)r;)rs rr-zSerializer.secret_keyîs€ð
×Ñ Ñ#Ð#rcóø—|€|j}|j}n
|}t|«} |r |j|jd««S|j|«S#t$r}t d|¬«|‚d}~wwxYw)aLoads the encoded object. This function raises
:class:`.BadPayload` if the payload is not valid. The
``serializer`` parameter can be used to override the serializer
stored on the class. The encoded ``payload`` should always be
bytes.
Núutf-8zSCould not load the payload because an exception occurred on unserializing the data.)Úoriginal_error)r#r$rÚdecodeÚ Exceptionr)rrr#Úuse_serializerÚis_textÚes rÚ load_payloadzSerializer.load_payloadõsŠ€ð Ð Ø!Ÿ_™_ˆNØ×-Ñ-‰Gà'ˆNÜ(¨Ó4ˆGð
ÙØ%×+Ñ+¨G¯N©N¸7Ó,CÓDÐDà!×'Ñ'¨Ó0Ð 0øÜò Üð7à ôðð 
ûð úsª!AÁ AÁ A9Á&A4Á4A9cób—t|jj|fi|j¤Ž«S)z¡Dumps the encoded object. The return value is always bytes.
If the internal serializer returns text, the value will be
encoded as UTF-8.
)rr#rr/rs rÚ dump_payloadzSerializer.dump_payloads,€ô
Ð/˜$Ÿ/™/×/Ñ/°ÑN°t×7MÑ7MÑNÓOÐOrcóp—|€ |j}|j|jfd|i|j¤ŽS)z‚Creates a new instance of the signer to be used. The default
implementation uses the :class:`.Signer` base class.
r.)r.r0r;r1)rr.s rÚ make_signerzSerializer.make_signers9€ð ˆ<Ø—9‘9ˆDàˆt�{‰{˜4×+Ñ+ÑM°$ÐM¸$×:LÑ:LÑMÐMrc#ó.K—|€ |j}|j|«–—|jD]a}t|t«r|}|j
}n"t|t «r|\}}n |j}|jD]}||fd|i|¤Ž–—ŒŒcy­w)z¯Iterates over all signers to be tried for unsigning. Starts
with the configured signer, then constructs each signer
specified in ``fallback_signers``.
Nr.) r.rKr2r!Údictr0Útupler1r;)rr.ÚfallbackÚkwargsr-s rÚiter_unsignerszSerializer.iter_unsigners!s“èø€ð
ˆ<Ø—9‘9ˆDà×јtÓ$Ò$à×-Ô-ˆHܘ(¤DÔ)Ø!�ØŸ;™;‘ܘH¤eÔ,Ø#+Ñ �™&à×+Ñ+�à"×.Ô.�
Ù˜zÑ?°Ð?¸Ñ?Ó?ñ/ñ.ùs‚BBcó´—t|j|««}|j|«j|«}|jr|j d«S|S)zÅReturns a signed string serialized with the internal
serializer. The return value can be either a byte or unicode
string depending on the format of the internal serializer.
r@)rrIrKÚsignr$rB)rrr.rÚrvs rrzSerializer.dumps7sQ€ô
˜T×.Ñ.¨sÓ3Ó4ˆØ
×
Ñ
˜dÓ
#×
(Ñ
(¨Ó
1ˆà × "Ò "Ø—9‘9˜WÓ%Ð %àˆ rcóF—|j|j||««y)zŠLike :meth:`dumps` but dumps into a file. The file handle has
to be compatible with what the internal serializer expects.
N)Úwriter)rrÚfr.s rÚdumpzSerializer.dumpDs€ð
�‰�—
‘
˜3 Ó%Õ&rc óð—t|«}d}|j|«D]$} |j|j|««cSt j t|«‚#t$r }|}Yd}~ŒQd}~wwxYw)ziReverse of :meth:`dumps`. Raises :exc:`.BadSignature` if the
signature validation fails.
N)rrQrGÚunsignrÚtÚcast)rÚsr.rPÚlast_exceptionr0Úerrs rrzSerializer.loadsJsp€ô
�q‹MˆØˆà×)Ñ)¨$Ö/ˆFð
%Ø×(Ñ(¨¯©°qÓ)9Ó:Ò:ð0ô �f‰f”\ >Ó2Ð2øô ò
%Ø!$•ûð
%ús£A Á A5Á)A0Á0A5cóB—|j|j«|«S)z)Like :meth:`loads` but loads from a file.)rÚread©rrWr.s rÚloadzSerializer.load[s€à�z‰z˜!Ÿ&™&›( DÓ)Ð)rcó&—|j||«S)a9Like :meth:`loads` but without verifying the signature. This
is potentially very dangerous to use depending on how your
serializer works. The return value is ``(signature_valid,
payload)`` instead of just the payload. The first item will be a
boolean that indicates if the signature is valid. This function
never fails.
Use it for debugging only and if you know that your serializer
module is not exploitable (for example, do not use it with a
pickle serializer).