OwlCyberSecurity - MANAGER
Edit File: middleware.cpython-39.pyc
a iH�f7 � @ 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 �`/home/gouroczh/virtualenv/test/3.9/lib/python3.9/site-packages/django/contrib/auth/middleware.pyr s r c @ s e Zd Zdd� ZdS )�AuthenticationMiddlewarec s( t � d�std��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> � 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. ZREMOTE_USERTc C s� t |d�std��z|j| j }W n, tyN | jrH|jjrH| �|� Y d S 0 |jjr||j� � | � ||�krrd S | �|� tj||d�}|r�||_t� ||� 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.)Zremote_user)r r ZMETA�header�KeyError�force_logout_if_no_headerr �is_authenticated�_remove_invalid_userZget_username�clean_usernamer Zauthenticate�login)r r �usernamer r r r r 0 s$ � z$RemoteUserMiddleware.process_requestc C s<