feat: redirect to OIDC login from Django admin
This commit is contained in:
parent
ab96727082
commit
46c6591170
|
@ -5,4 +5,5 @@ from . import views
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", views.index, name="index"),
|
path("", views.index, name="index"),
|
||||||
path("unauthorized", views.unauthorized, name="unauthorized"),
|
path("unauthorized", views.unauthorized, name="unauthorized"),
|
||||||
|
path("admin/login/", views.admin_login),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.shortcuts import render
|
from django.http import QueryDict
|
||||||
|
from django.shortcuts import redirect, render
|
||||||
|
from django.urls import reverse
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -9,3 +11,13 @@ def index(request):
|
||||||
|
|
||||||
def unauthorized(request):
|
def unauthorized(request):
|
||||||
return render(request, "core/unauthorized.html", {})
|
return render(request, "core/unauthorized.html", {})
|
||||||
|
|
||||||
|
|
||||||
|
def admin_login(request):
|
||||||
|
query = ""
|
||||||
|
if next := request.GET.get("next"):
|
||||||
|
q = QueryDict(mutable=True)
|
||||||
|
q["next"] = next
|
||||||
|
query = f"?{q.urlencode()}"
|
||||||
|
|
||||||
|
return redirect(f"{reverse('oidc_authentication_init')}{query}")
|
||||||
|
|
Loading…
Reference in New Issue