
    g                     Z    d dl Z d dlmZ d dlmZ d dlmZ  G d dej                        Zy)    N)HttpRequest)authentication)authenticate_by_x_session_tokenc                   F    e Zd ZdZdefdZdedej                  e   fdZ	y)XSessionTokenAuthenticationzz
    This authentication class uses the X-Session-Token that django-allauth
    is using for authentication purposes.
    requestc                 @    | j                  |      }|rt        |      S y )N)get_session_tokenr   )selfr   tokens      s/var/www/django_project/virt/lib/python3.12/site-packages/allauth/headless/contrib/rest_framework/authentication.pyauthenticatez(XSessionTokenAuthentication.authenticate   s#    &&w/2599    returnc                 8    |j                   j                  d      S )z
        Returns the session token for the given request, by looking up the
        ``X-Session-Token`` header. Override this if you want to extract the token
        from e.g. the ``Authorization`` header.
        zX-Session-Token)headersget)r   r   s     r   r
   z-XSessionTokenAuthentication.get_session_token   s     ""#455r   N)
__name__
__module____qualname____doc__r   r   typingOptionalstrr
    r   r   r   r      s/    
K 6 69M 6r   r   )	r   django.httpr   rest_frameworkr   $allauth.headless.internal.sessionkitr   BaseAuthenticationr   r   r   r   <module>r       s%     # )
6."C"C 6r   