Autologin
Some checks are pending
Docker hub build / docker (push) Waiting to run

This commit is contained in:
A B
2024-10-28 00:06:35 +00:00
parent b6ad6e8578
commit 7cf99af20d
5 changed files with 33 additions and 18 deletions

View File

@ -1,6 +1,5 @@
from django.urls import resolve
from django.http import Http404, HttpResponseNotFound
from django.contrib.auth.middleware import RemoteUserMiddleware
from django.contrib.auth import authenticate, login
from django.utils.deprecation import MiddlewareMixin
class RequestLogger:
def __init__(self, get_response):
@ -15,5 +14,9 @@ class RequestLogger:
return response
class AutoLoginMiddleware(RemoteUserMiddleware):
header = "HTTP_X_AUTHENTIK_USERNAME"
class AutoLoginMiddleware(MiddlewareMixin):
def process_request(self, request):
if not request.user.is_authenticated:
user = authenticate(username='admin', password='admin')
if user:
login(request, user)