2024-09-20 10:42:37 +00:00
|
|
|
from django.contrib.auth import authenticate
|
2024-09-20 11:06:43 +00:00
|
|
|
from django.http import HttpResponseForbidden, HttpResponseRedirect
|
|
|
|
from django.shortcuts import redirect, render
|
2024-09-20 10:42:37 +00:00
|
|
|
from django.utils.translation import gettext as _
|
|
|
|
|
2024-09-17 15:39:46 +00:00
|
|
|
|
|
|
|
# Create your views here.
|
2024-09-20 10:42:37 +00:00
|
|
|
def certificate_login(request):
|
|
|
|
certificate = request.META.get('HTTP_X_SSL_CERT', None)
|
|
|
|
|
|
|
|
user = authenticate(request, encoded_certificate=certificate)
|
|
|
|
|
|
|
|
if not user:
|
|
|
|
return HttpResponseForbidden(_("you have not sent a valid client certificate"))
|
|
|
|
|
|
|
|
if "next" in request.GET:
|
|
|
|
return HttpResponseRedirect(request.GET["next"])
|
|
|
|
|
|
|
|
return redirect("home")
|
|
|
|
|
|
|
|
|
|
|
|
def home_page(request):
|
2024-09-20 11:06:43 +00:00
|
|
|
return render(request, "home.html")
|