
    0h<                       S SK Jr  S SKJr  S SKrS SKrS SKJr  S SK	J	r	  S SK	J
r
  S SKJr  S SKJr  S SKJr  S	S
KJr  \R$                  (       a  S SKrS	SKJr  S	SKJr  S	SKJr   " S S\\\R6                  4   5      r " S S\\\R6                  4   \5      r " S S\5      r " S S5      r\" 5       r SSS jjr! " S S\5      r"g)    )annotationsN)MutableMapping)datetime)timezone)BadSignature)URLSafeTimedSerializer)CallbackDict   )TaggedJSONSerializer)Flask)Request)Responsec                  `    \ rS rSrSr\S	S j5       r\R                  S
S j5       rSrSr	Sr
Srg)SessionMixin   z3Expands a basic dictionary with session attributes.c                &    U R                  SS5      $ )z3This reflects the ``'_permanent'`` key in the dict.
_permanentF)getselfs    F/var/www/auris/envauris/lib/python3.13/site-packages/flask/sessions.py	permanentSessionMixin.permanent   s     xxe,,    c                     [        U5      U S'   g )Nr   )bool)r   values     r   r   r       s    !%[\r   FT N)returnr   )r   r   r   None)__name__
__module____qualname____firstlineno____doc__propertyr   setternewmodifiedaccessed__static_attributes__r   r   r   r   r      sF    =- - ) ) C
 H
 Hr   r   c                  |   ^  \ rS rSrSrSrSr S	   S
U 4S jjjrSU 4S jjrS	SU 4S jjjr	S	SU 4S jjjr
SrU =r$ )SecureCookieSession4   zBase class for sessions based on signed cookies.

This session backend will set the :attr:`modified` and
:attr:`accessed` attributes. It cannot reliably track whether a
session is new (vs. empty), so :attr:`new` remains hard coded to
``False``.
Fc                .   > SS jn[         TU ]  X5        g )Nc                     SU l         SU l        g NT)r)   r*   r   s    r   	on_update/SecureCookieSession.__init__.<locals>.on_updateN   s     DM DMr   )r   zte.Selfr   r    )super__init__)r   initialr2   	__class__s      r   r5   SecureCookieSession.__init__J   s    	! 	,r   c                0   > SU l         [        TU ]	  U5      $ r1   )r*   r4   __getitem__)r   keyr7   s     r   r:   SecureCookieSession.__getitem__T   s    w"3''r   c                0   > SU l         [        TU ]	  X5      $ r1   )r*   r4   r   r   r;   defaultr7   s      r   r   SecureCookieSession.getX   s    w{3((r   c                0   > SU l         [        TU ]	  X5      $ r1   )r*   r4   
setdefaultr>   s      r   rB   SecureCookieSession.setdefault\   s    w!#//r   )r*   r)   )N)r6   z<c.Mapping[str, t.Any] | c.Iterable[tuple[str, t.Any]] | Noner   r    )r;   strr   t.Any)r;   rD   r?   rE   r   rE   )r!   r"   r#   r$   r%   r)   r*   r5   r:   r   rB   r+   __classcell__)r7   s   @r   r-   r-   4   sR     H H QU-M- 
- -() )0 0r   r-   c                  @    \ rS rSrSrSS jr\=r=r=r=r	=r
=rrCSrg)NullSessiona   zClass used to generate nicer error messages if sessions are not
available.  Will still allow read-only access to the empty session
but fail on setting.
c                    [        S5      e)NzThe session is unavailable because no secret key was set.  Set the secret_key on the application to something unique and secret.)RuntimeError)r   argskwargss      r   _failNullSession._failg   s    :
 	
r   r   N)rL   rE   rM   rE   r   z
t.NoReturn)r!   r"   r#   r$   r%   rN   __setitem____delitem__clearpoppopitemupdaterB   r+   r   r   r   rH   rH   a   s6    

 OTSKS+SSSgSr   rH   c                      \ rS rSrSr\rSrSS jrSS jr	SS jr
SS jrSS jrSS	 jrSS
 jrSS jrSS jrSS jrSS jrSS jr        SS jrSrg)SessionInterfacer   a  The basic interface you have to implement in order to replace the
default session interface which uses werkzeug's securecookie
implementation.  The only methods you have to implement are
:meth:`open_session` and :meth:`save_session`, the others have
useful defaults which you don't need to change.

The session object returned by the :meth:`open_session` method has to
provide a dictionary like interface plus the properties and methods
from the :class:`SessionMixin`.  We recommend just subclassing a dict
and adding that mixin::

    class Session(dict, SessionMixin):
        pass

If :meth:`open_session` returns ``None`` Flask will call into
:meth:`make_null_session` to create a session that acts as replacement
if the session support cannot work because some requirement is not
fulfilled.  The default :class:`NullSession` class that is created
will complain that the secret key was not set.

To replace the session interface on an application all you have to do
is to assign :attr:`flask.Flask.session_interface`::

    app = Flask(__name__)
    app.session_interface = MySessionInterface()

Multiple requests with the same session may be sent and handled
concurrently. When implementing a new session interface, consider
whether reads or writes to the backing store must be synchronized.
There is no guarantee on the order in which the session for each
request is opened or saved, it will occur in the order that requests
begin and end processing.

.. versionadded:: 0.8
Fc                "    U R                  5       $ )a  Creates a null session which acts as a replacement object if the
real session support could not be loaded due to a configuration
error.  This mainly aids the user experience because the job of the
null session is to still support lookup without complaining but
modifications are answered with a helpful error message of what
failed.

This creates an instance of :attr:`null_session_class` by default.
)null_session_classr   apps     r   make_null_session"SessionInterface.make_null_session   s     &&((r   c                ,    [        XR                  5      $ )zChecks if a given object is a null session.  Null sessions are
not asked to be saved.

This checks if the object is an instance of :attr:`null_session_class`
by default.
)
isinstancerZ   )r   objs     r   is_null_session SessionInterface.is_null_session   s     #6677r   c                     UR                   S   $ )zJThe name of the session cookie. Uses``app.config["SESSION_COOKIE_NAME"]``.SESSION_COOKIE_NAMEconfigr[   s     r   get_cookie_name SessionInterface.get_cookie_name   s    zz/00r   c                     UR                   S   $ )ac  The value of the ``Domain`` parameter on the session cookie. If not set,
browsers will only send the cookie to the exact domain it was set from.
Otherwise, they will send it to any subdomain of the given value as well.

Uses the :data:`SESSION_COOKIE_DOMAIN` config.

.. versionchanged:: 2.3
    Not set by default, does not fall back to ``SERVER_NAME``.
SESSION_COOKIE_DOMAINrf   r[   s     r   get_cookie_domain"SessionInterface.get_cookie_domain   s     zz122r   c                L    UR                   S   =(       d    UR                   S   $ )zReturns the path for which the cookie should be valid.  The
default implementation uses the value from the ``SESSION_COOKIE_PATH``
config var if it's set, and falls back to ``APPLICATION_ROOT`` or
uses ``/`` if it's ``None``.
SESSION_COOKIE_PATHAPPLICATION_ROOTrf   r[   s     r   get_cookie_path SessionInterface.get_cookie_path   s#     zz/0RCJJ?Q4RRr   c                     UR                   S   $ )zReturns True if the session cookie should be httponly.  This
currently just returns the value of the ``SESSION_COOKIE_HTTPONLY``
config var.
SESSION_COOKIE_HTTPONLYrf   r[   s     r   get_cookie_httponly$SessionInterface.get_cookie_httponly       
 zz344r   c                     UR                   S   $ )z~Returns True if the cookie should be secure.  This currently
just returns the value of the ``SESSION_COOKIE_SECURE`` setting.
SESSION_COOKIE_SECURErf   r[   s     r   get_cookie_secure"SessionInterface.get_cookie_secure   s     zz122r   c                     UR                   S   $ )zReturn ``'Strict'`` or ``'Lax'`` if the cookie should use the
``SameSite`` attribute. This currently just returns the value of
the :data:`SESSION_COOKIE_SAMESITE` setting.
SESSION_COOKIE_SAMESITErf   r[   s     r   get_cookie_samesite$SessionInterface.get_cookie_samesite   rw   r   c                     UR                   S   $ )zReturns True if the cookie should be partitioned. By default, uses
the value of :data:`SESSION_COOKIE_PARTITIONED`.

.. versionadded:: 3.1
SESSION_COOKIE_PARTITIONEDrf   r[   s     r   get_cookie_partitioned'SessionInterface.get_cookie_partitioned   s     zz677r   c                    UR                   (       a1  [        R                  " [        R                  5      UR
                  -   $ g)zA helper method that returns an expiration date for the session
or ``None`` if the session is linked to the browser session.  The
default implementation returns now + the permanent session
lifetime configured on the application.
N)r   r   nowr   utcpermanent_session_lifetimer   r\   sessions      r   get_expiration_time$SessionInterface.get_expiration_time   s.     <<-0N0NNNr   c                l    UR                   =(       d"    UR                  =(       a    UR                  S   $ )aq  Used by session backends to determine if a ``Set-Cookie`` header
should be set for this session cookie for this response. If the session
has been modified, the cookie is set. If the session is permanent and
the ``SESSION_REFRESH_EACH_REQUEST`` config is true, the cookie is
always set.

This check is usually skipped if the session was deleted.

.. versionadded:: 0.11
SESSION_REFRESH_EACH_REQUEST)r)   r   rg   r   s      r   should_set_cookie"SessionInterface.should_set_cookie   s/      
L#**-K"L	
r   c                    [        5       e)a  This is called at the beginning of each request, after
pushing the request context, before matching the URL.

This must return an object which implements a dictionary-like
interface as well as the :class:`SessionMixin` interface.

This will return ``None`` to indicate that loading failed in
some way that is not immediately an error. The request
context will fall back to using :meth:`make_null_session`
in this case.
NotImplementedError)r   r\   requests      r   open_sessionSessionInterface.open_session  s     "##r   c                    [        5       e)zThis is called at the end of each request, after generating
a response, before removing the request context. It is skipped
if :meth:`is_null_session` returns ``True``.
r   )r   r\   r   responses       r   save_sessionSessionInterface.save_session  s     "##r   r   N)r\   r   r   rH   )ra   objectr   r   )r\   r   r   rD   )r\   r   r   z
str | None)r\   r   r   r   )r\   r   r   r   r   zdatetime | None)r\   r   r   r   r   r   )r\   r   r   r   r   zSessionMixin | Noner\   r   r   r   r   r   r   r    )r!   r"   r#   r$   r%   rH   rZ   pickle_basedr]   rb   rh   rl   rq   ru   rz   r~   r   r   r   r   r   r+   r   r   r   rW   rW   r   sy    "P % L
)81
3S5358
 $$$#/$;C$	$r   rW   c                .    [         R                  " U 5      $ )zDon't access ``hashlib.sha1`` until runtime. FIPS builds may not include
SHA-1, in which case the import and use as a default would fail before the
developer can configure something else.
)hashlibsha1)strings    r   
_lazy_sha1r   "  s    
 <<r   c                  f    \ rS rSrSrSr\" \5      rSr	\
r\rS
S jrSS jr        SS jrSrg	)SecureCookieSessionInterfacei*  zmThe default session interface that stores sessions in signed cookies
through the :mod:`itsdangerous` module.
zcookie-sessionhmacc                   UR                   (       d  g / nUR                  S   =n(       a  UR                  U5        UR                  UR                   5        [	        UU R
                  U R                  U R                  U R                  S.S9$ )NSECRET_KEY_FALLBACKS)key_derivationdigest_method)salt
serializersigner_kwargs)	
secret_keyrg   extendappendr   r   r   r   r   )r   r\   keys	fallbackss       r   get_signing_serializer3SecureCookieSessionInterface.get_signing_serializer=  sw    ~~"$

#9::9:KK	"CNN#%"&"5"5!%!3!3	
 	
r   c                v   U R                  U5      nUc  g UR                  R                  U R                  U5      5      nU(       d  U R	                  5       $ [        UR                  R                  5       5      n UR                  XES9nU R	                  U5      $ ! [         a    U R	                  5       s $ f = f)N)max_age)
r   cookiesr   rh   session_classintr   total_secondsloadsr   )r   r\   r   svalr   datas          r   r   )SecureCookieSessionInterface.open_sessionQ  s    '',9oo!!$"6"6s";<%%''c44BBDE	(77370D%%d++ 	(%%''	(s   ;B B87B8c                   U R                  U5      nU R                  U5      nU R                  U5      nU R                  U5      nU R	                  U5      nU R                  U5      n	U R                  U5      n
UR                  (       a  UR                  R                  S5        U(       dB  UR                  (       a0  UR                  UUUUUU	U
S9  UR                  R                  S5        g U R                  X5      (       d  g U R                  X5      nU R                  U5      R                  [!        U5      5      nUR#                  UUUU
UUUUU	S9	  UR                  R                  S5        g )NCookie)domainpathsecurepartitionedsamesitehttponly)expiresr   r   r   r   r   r   )rh   rl   rq   rz   r   r~   ru   r*   varyaddr)   delete_cookier   r   r   dumpsdict
set_cookie)r   r\   r   r   namer   r   r   r   r   r   r   r   s                r   r   )SecureCookieSessionInterface.save_session_  sc    ##C('',##C('',11#6++C0++C0 MMh' &&!! +%% '  !!(+%%c33**38))#.44T']C# 	 
	
 	(#r   r   N)r\   r   r   zURLSafeTimedSerializer | None)r\   r   r   r   r   zSecureCookieSession | Noner   )r!   r"   r#   r$   r%   r   staticmethodr   r   r   session_json_serializerr   r-   r   r   r   r   r+   r   r   r   r   r   *  sZ     D ,M N )J'M
((0$0$#/0$;C0$	0$r   r   )r   )r   bytesr   rE   )#
__future__r   collections.abcabccr   typingtr   r   r   itsdangerousr   r   werkzeug.datastructuresr	   json.tagr   TYPE_CHECKINGtyping_extensionster\   r   wrappersr   r   rD   Anyr   r-   rH   rW   r   r   r   r   r   r   <module>r      s    "    *   % / 0 *??"!">#quu*- 8*0,sAEEz2L *0Z% "j$ j$Z /0  e$#3 e$r   