File manager - Edit - /usr/local/CyberCP/lib/python3.10/site-packages/django/contrib/auth/__pycache__/middleware.cpython-310.pyc
Back
o �h7 � @ s� d dl mZ d dlmZ d dlmZ d dlmZ d dlm Z d dl mZ dd� ZG d d � d e �Z G dd� de �ZG d d� de�ZdS )� )�auth)�load_backend)�RemoteUserBackend)�ImproperlyConfigured)�MiddlewareMixin)�SimpleLazyObjectc C s t | d�st�| �| _| jS )N�_cached_user)�hasattrr �get_userr ��request� r �Q/usr/local/CyberCP/lib/python3.10/site-packages/django/contrib/auth/middleware.pyr s r c @ s e Zd Zdd� ZdS )�AuthenticationMiddlewarec s( t � d�s td��t� fdd��� _d S )N�sessionz�The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE setting to insert 'django.contrib.sessions.middleware.SessionMiddleware' before 'django.contrib.auth.middleware.AuthenticationMiddleware'.c s t � �S )N)r r r r r �<lambda> s z:AuthenticationMiddleware.process_request.<locals>.<lambda>)r r r �user)�selfr r r r �process_request s �z(AuthenticationMiddleware.process_requestN)�__name__� __module__�__qualname__r r r r r r s r c @ s0 e Zd ZdZdZdZdd� Zdd� Zdd � Zd S )�RemoteUserMiddlewarea� Middleware for utilizing web-server-provided authentication. If request.user is not authenticated, then this middleware attempts to authenticate the username passed in the ``REMOTE_USER`` request header. If authentication is successful, the user is automatically logged in to persist the user in the session. The header used is configurable and defaults to ``REMOTE_USER``. Subclass this class and change the ``header`` attribute if you need to use a different header. �REMOTE_USERTc C s� t |d�s td��z|j| j }W n ty' | jr$|jjr$| �|� Y d S w |jjr>|j� � | � ||�kr9d S | �|� tj||d�}|rR||_t� ||� d S d S )Nr z�The Django remote user auth middleware requires the authentication middleware to be installed. Edit your MIDDLEWARE setting to insert 'django.contrib.auth.middleware.AuthenticationMiddleware' before the RemoteUserMiddleware class.)�remote_user)r r �META�header�KeyError�force_logout_if_no_headerr �is_authenticated�_remove_invalid_user�get_username�clean_usernamer �authenticate�login)r r �usernamer r r r r 0 s( � � �z$RemoteUserMiddleware.process_requestc C s<