
    fs                         d dl mZ d dlmZ d dlmZ d dlmZ  eej                        Z	e	j                  Z
 G d d      Zy)    )import_module)urlparse)settings)patch_vary_headersc                   "    e Zd ZdZd Zd Zd Zy)LoginSessionaT  Some providers sometimes POST their responses, which due to
    CORS/Samesite-cookie rules means that this request cannot access the session
    as its session cookie is unavailable.

    We work around this by storing the response in a separate, temporary session
    and redirecting to a different endpoint that can pick up the flow.
    c                     || _         || _        || _        t        ||d      | _        | j                  C|j
                  j                  |      }t        |      | _        t        ||| j                         yy)z8
        Prepares an provider specific session.
        N)	requestattribute_namecookie_namegetattrstoreCOOKIESgetSessionStoresetattr)selfr
   r   r   session_keys        Y/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/allauth/socialaccount/sessions.py__init__zLoginSession.__init__   sj     ,&Wnd;
::!//--k:K%k2DJG^TZZ8     c           
      h   t        |d       | j                  j                          i }t        t        dd      }|r||d<    |j
                  | j                  | j                  j                  fddt        j                  t        |j                        j                  t        j                  dd| y)z4
        Save the session and set a cookie.
        )CookieSESSION_COOKIE_SAMESITENsamesite)max_ageexpiresdomainpathsecurehttponly)r   r   saver   r   
set_cookier   r   SESSION_COOKIE_DOMAINr   urlr   SESSION_COOKIE_SECURE)r   responsekwargsr   s       r   r"   zLoginSession.save"   s     	8[1

8%>E!)F:JJ""	
 11(,,',,11	
 	
r   c                 8    | j                   j                          y )N)r   delete)r   s    r   r*   zLoginSession.delete9   s    

r   N)__name__
__module____qualname____doc__r   r"   r*    r   r   r   r      s    9
.r   r   N)	importlibr   urllib.parser   django.confr   django.utils.cacher   SESSION_ENGINEenginer   r   r/   r   r   <module>r6      s8    # !   1 
x..	/"". .r   