{{ title }}
{% endif %}{% endblock %} + {% block content %} + {% block object-tools %}{% endblock %} + {{ content }} + {% endblock %} + {% block sidebar %}{% endblock %} ++
diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 7540d5b..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "jdav_web/jet"] - path = jdav_web/jet - url = https://git.flavigny.de/jdavlb/jet/ diff --git a/jdav_web/jdav_web/settings/__init__.py b/jdav_web/jdav_web/settings/__init__.py index 1fe9471..248f7d1 100644 --- a/jdav_web/jdav_web/settings/__init__.py +++ b/jdav_web/jdav_web/settings/__init__.py @@ -58,6 +58,7 @@ base_settings = [ 'components/emails.py', 'components/texts.py', 'components/locale.py', + 'components/oauth.py', ] include(*base_settings) diff --git a/jdav_web/jdav_web/settings/components/base.py b/jdav_web/jdav_web/settings/components/base.py index e546624..f3b5d89 100644 --- a/jdav_web/jdav_web/settings/components/base.py +++ b/jdav_web/jdav_web/settings/components/base.py @@ -52,6 +52,7 @@ INSTALLED_APPS = [ 'django_celery_beat', 'rules', 'jet', + 'oauth2_provider', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', @@ -196,3 +197,5 @@ STARTPAGE_URL_NAME_PATTERN = "[\w\-: *]" # admins to contact on error messages ADMINS = get_var('section', 'admins', default=[]) + +LOGIN_URL = '/de/kompass/login/' diff --git a/jdav_web/jdav_web/settings/components/oauth.py b/jdav_web/jdav_web/settings/components/oauth.py new file mode 100644 index 0000000..5e8b831 --- /dev/null +++ b/jdav_web/jdav_web/settings/components/oauth.py @@ -0,0 +1,11 @@ +OAUTH2_PROVIDER = { + "OIDC_ENABLED": True, + "PKCE_REQUIRED": False, + "OAUTH2_VALIDATOR_CLASS": "logindata.oauth.CustomOAuth2Validator", + "OIDC_RSA_PRIVATE_KEY": get_var('oauth', 'oidc_rsa_private_key', default=''), + "SCOPES": { + "openid": "OpenID Connect scope", + "profile": "profile scope", + "email": "email scope", + }, +} diff --git a/jdav_web/jdav_web/urls.py b/jdav_web/jdav_web/urls.py index b32210c..1b034c0 100644 --- a/jdav_web/jdav_web/urls.py +++ b/jdav_web/jdav_web/urls.py @@ -13,13 +13,14 @@ Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ -from django.urls import re_path, include +from django.urls import path, re_path, include from django.contrib import admin from django.conf.urls.static import static from django.conf.urls.i18n import i18n_patterns from django.conf import settings from django.utils.translation import gettext_lazy as _ from django.views.generic.base import RedirectView +from oauth2_provider import urls as oauth2_urls from .views import media_access admin.site.index_title = _('Startpage') @@ -36,6 +37,7 @@ urlpatterns = i18n_patterns( re_path(r'^LBAlpin/Programm(/)?(20)?[0-9]{0,2}', include('ludwigsburgalpin.urls', namespace="ludwigsburgalpin")), re_path(r'^_nested_admin/', include('nested_admin.urls')), + path('o/', include(oauth2_urls)), re_path(r'^', include('startpage.urls', namespace="startpage")), ) diff --git a/jdav_web/jet b/jdav_web/jet deleted file mode 160000 index 0126d55..0000000 --- a/jdav_web/jet +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0126d5596fcba43730ecc7e6cbc0987b12f0640d diff --git a/jdav_web/logindata/oauth.py b/jdav_web/logindata/oauth.py new file mode 100644 index 0000000..ee0e5f3 --- /dev/null +++ b/jdav_web/logindata/oauth.py @@ -0,0 +1,13 @@ +from oauth2_provider.oauth2_validators import OAuth2Validator + + +class CustomOAuth2Validator(OAuth2Validator): + # Set `oidc_claim_scope = None` to ignore scopes that limit which claims to return, + # otherwise the OIDC standard scopes are used. + + def get_additional_claims(self, request): + if request.user.member: + context = {'email': request.user.member.email} + else: + context = {} + return dict(context, preferred_username=request.user.username) diff --git a/jdav_web/templates/admin/base.html b/jdav_web/templates/admin/base.html new file mode 100644 index 0000000..f7d55f2 --- /dev/null +++ b/jdav_web/templates/admin/base.html @@ -0,0 +1,439 @@ +{% load i18n static jet_tags %} +{% get_current_language as LANGUAGE_CODE %}{% get_current_language_bidi as LANGUAGE_BIDI %} +{% jet_get_current_theme as THEME %} +{% jet_get_current_version as JET_VERSION %} +{% block html %} +
+