mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-07 18:58:30 +02:00
Add support for OIDC (#389)
* added support for oidc auth * fixed oidc usernames * hiding password for users that aren't logged in via local auth * add dependency, update settings * keep change password link * add tests * add docs --------- Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@gmail.com>
This commit is contained in:
@@ -19,16 +19,27 @@ from django.contrib.auth import views as auth_views
|
||||
from django.urls import path, include
|
||||
|
||||
from bookmarks.admin import linkding_admin_site
|
||||
from .settings import ALLOW_REGISTRATION, DEBUG
|
||||
|
||||
|
||||
class LinkdingLoginView(auth_views.LoginView):
|
||||
"""
|
||||
Custom login view to lazily add additional context data
|
||||
Allows to override settings in tests
|
||||
"""
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
context["allow_registration"] = settings.ALLOW_REGISTRATION
|
||||
context["enable_oidc"] = settings.LD_ENABLE_OIDC
|
||||
return context
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path("admin/", linkding_admin_site.urls),
|
||||
path(
|
||||
"login/",
|
||||
auth_views.LoginView.as_view(
|
||||
redirect_authenticated_user=True,
|
||||
extra_context=dict(allow_registration=ALLOW_REGISTRATION),
|
||||
),
|
||||
LinkdingLoginView.as_view(redirect_authenticated_user=True),
|
||||
name="login",
|
||||
),
|
||||
path("logout/", auth_views.LogoutView.as_view(), name="logout"),
|
||||
@@ -45,13 +56,16 @@ urlpatterns = [
|
||||
path("", include("bookmarks.urls")),
|
||||
]
|
||||
|
||||
if settings.LD_ENABLE_OIDC:
|
||||
urlpatterns.append(path("oidc/", include("mozilla_django_oidc.urls")))
|
||||
|
||||
if settings.LD_CONTEXT_PATH:
|
||||
urlpatterns = [path(settings.LD_CONTEXT_PATH, include(urlpatterns))]
|
||||
|
||||
if DEBUG:
|
||||
if settings.DEBUG:
|
||||
import debug_toolbar
|
||||
|
||||
urlpatterns.append(path("__debug__/", include(debug_toolbar.urls)))
|
||||
|
||||
if ALLOW_REGISTRATION:
|
||||
if settings.ALLOW_REGISTRATION:
|
||||
urlpatterns.append(path("", include("django_registration.backends.one_step.urls")))
|
||||
|
Reference in New Issue
Block a user