# Requirements update
* updates requirements.txt * drops django-simple-sso from codebase and requirements.txt
This commit is contained in:
parent
35b1409359
commit
93a71a7055
@ -1,78 +0,0 @@
|
||||
"""
|
||||
Author: Michel Peltriaux
|
||||
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
|
||||
Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 17.08.21
|
||||
|
||||
"""
|
||||
from django.http import HttpResponse
|
||||
from django.urls import re_path
|
||||
from django.views import View
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from itsdangerous import TimedSerializer
|
||||
from simple_sso.sso_client.client import Client
|
||||
|
||||
from user.models import User
|
||||
|
||||
|
||||
class PropagateView(View):
|
||||
""" View used to receive propagated sso-server user data
|
||||
|
||||
"""
|
||||
client = None
|
||||
signer = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.signer = TimedSerializer(self.client.private_key)
|
||||
|
||||
@csrf_exempt
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def post(self, request):
|
||||
user_data = request.body
|
||||
user_data = self.signer.loads(user_data)
|
||||
self.client.build_user(user_data)
|
||||
return HttpResponse(status=200)
|
||||
|
||||
|
||||
class KonovaSSOClient(Client):
|
||||
""" Konova specialized derivative of general sso.Client.
|
||||
|
||||
Adds some custom behaviour for konova usage.
|
||||
|
||||
"""
|
||||
propagate_view = PropagateView
|
||||
|
||||
def get_urls(self):
|
||||
urls = super().get_urls()
|
||||
urls += re_path(r'^propagate/$', self.propagate_view.as_view(client=self), name='simple-sso-propagate'),
|
||||
return urls
|
||||
|
||||
def build_user(self, user_data):
|
||||
""" Creates a user or updates user data
|
||||
|
||||
Args:
|
||||
user_data ():
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
try:
|
||||
user = User.objects.get(username=user_data['username'])
|
||||
# Update user data, excluding some changes
|
||||
skipable_attrs = {
|
||||
"username",
|
||||
"is_staff",
|
||||
"is_superuser",
|
||||
}
|
||||
for _attr, _val in user_data.items():
|
||||
if _attr in skipable_attrs:
|
||||
continue
|
||||
setattr(user, _attr, _val)
|
||||
except User.DoesNotExist:
|
||||
user = User(**user_data)
|
||||
user.set_unusable_password()
|
||||
user.save()
|
||||
return user
|
@ -5,14 +5,10 @@ Contact: michel.peltriaux@sgdnord.rlp.de
|
||||
Created on: 31.01.22
|
||||
|
||||
"""
|
||||
import random
|
||||
import string
|
||||
|
||||
# Django-simple-SSO settings
|
||||
# SSO settings
|
||||
SSO_SERVER_BASE = "http://127.0.0.1:8000/"
|
||||
SSO_SERVER = f"{SSO_SERVER_BASE}sso/"
|
||||
SSO_PRIVATE_KEY = "CHANGE_ME"
|
||||
SSO_PUBLIC_KEY = "CHANGE_ME"
|
||||
|
||||
# OAuth settings
|
||||
OAUTH_CODE_VERIFIER = "CHANGE_ME"
|
||||
|
@ -16,18 +16,14 @@ Including another URLconf
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
from konova.settings import SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY, DEBUG
|
||||
from konova.sso.sso import KonovaSSOClient
|
||||
from konova.views.logout import LogoutView
|
||||
from konova.views.geometry import GeomParcelsView, GeomParcelsContentView
|
||||
from konova.views.home import HomeView
|
||||
from konova.views.map_proxy import ClientProxyParcelSearch, ClientProxyParcelWFS
|
||||
from konova.views.oauth import OAuthLoginView, OAuthCallbackView
|
||||
|
||||
sso_client = KonovaSSOClient(SSO_SERVER, SSO_PUBLIC_KEY, SSO_PRIVATE_KEY)
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('login/', include(sso_client.get_urls())),
|
||||
path('oauth/callback/', OAuthCallbackView.as_view(), name="oauth-callback"),
|
||||
path('oauth/login/', OAuthLoginView.as_view(), name="oauth-login"),
|
||||
path('logout/', LogoutView.as_view(), name="logout"),
|
||||
|
@ -24,13 +24,11 @@ django-environ==0.11.2
|
||||
django-filter==24.2
|
||||
django-fontawesome-5==1.0.18
|
||||
django-oauth-toolkit==2.4.0
|
||||
django-simple-sso==1.2.0
|
||||
django-tables2==2.7.0
|
||||
et-xmlfile==1.1.0
|
||||
gunicorn==22.0.0
|
||||
idna==3.7
|
||||
importlib_metadata==7.1.0
|
||||
itsdangerous==0.24
|
||||
jwcrypto==1.5.6
|
||||
kombu==5.3.7
|
||||
oauthlib==3.2.2
|
||||
@ -59,7 +57,6 @@ tzdata==2024.1
|
||||
urllib3==2.2.1
|
||||
vine==5.1.0
|
||||
wcwidth==0.2.13
|
||||
webservices==0.7
|
||||
wrapt==1.16.0
|
||||
xmltodict==0.13.0
|
||||
zipp==3.19.2
|
||||
|
Loading…
Reference in New Issue
Block a user