From 61790d2261b5087c510d5ce3ea3c0c2d768dd7bd Mon Sep 17 00:00:00 2001 From: wh1te909 <7434746+wh1te909@users.noreply.github.com> Date: Fri, 18 Oct 2024 20:26:53 +0000 Subject: [PATCH] blacked --- api/tacticalrmm/ee/sso/permissions.py | 3 ++- api/tacticalrmm/ee/sso/views.py | 17 +++++++---------- api/tacticalrmm/tacticalrmm/urls.py | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/api/tacticalrmm/ee/sso/permissions.py b/api/tacticalrmm/ee/sso/permissions.py index 164ea284..fb6af4da 100644 --- a/api/tacticalrmm/ee/sso/permissions.py +++ b/api/tacticalrmm/ee/sso/permissions.py @@ -1,8 +1,9 @@ from rest_framework import permissions from allauth.socialaccount.models import SocialAccount + class SSOLoginPerms(permissions.BasePermission): def has_permission(self, r, view): connected_apps = SocialAccount.objects.filter(user=r.user) - return len(connected_apps) > 0 \ No newline at end of file + return len(connected_apps) > 0 diff --git a/api/tacticalrmm/ee/sso/views.py b/api/tacticalrmm/ee/sso/views.py index 52e1a328..01443772 100644 --- a/api/tacticalrmm/ee/sso/views.py +++ b/api/tacticalrmm/ee/sso/views.py @@ -23,6 +23,7 @@ from logs.models import AuditLog from tacticalrmm.utils import get_core_settings from .permissions import SSOLoginPerms + class SocialAppSerializer(ModelSerializer): server_url = ReadOnlyField(source="settings.server_url") role = ReadOnlyField(source="settings.role") @@ -63,7 +64,7 @@ class GetAddSSOProvider(APIView): "provider", "provider_id", "settings", - "role" + "role", ] # removed any special characters and replaces spaces with a hyphen @@ -112,9 +113,7 @@ class GetUpdateDeleteSSOProvider(APIView): data["settings"]["server_url"] = data["server_url"] data["settings"]["role"] = data["role"] if data["role"] else None - serializer = self.InputSerialzer( - instance=provider, data=data, partial=True - ) + serializer = self.InputSerialzer(instance=provider, data=data, partial=True) serializer.is_valid(raise_exception=True) serializer.save() return Response("ok") @@ -130,9 +129,9 @@ class GetAccessToken(KnoxLoginView): authentication_classes = [SessionAuthentication] def post(self, request, format=None): - + core = get_core_settings() - + # check for auth method before signing in if ( core.sso_enabled @@ -163,9 +162,7 @@ class GetAccessToken(KnoxLoginView): return Response(response.data) else: logout(request) - return Response( - "No pending login session found", status.HTTP_403_FORBIDDEN - ) + return Response("No pending login session found", status.HTTP_403_FORBIDDEN) class GetUpdateSSOSettings(APIView): @@ -178,7 +175,7 @@ class GetUpdateSSOSettings(APIView): return Response( { "block_local_user_logon": core_settings.block_local_user_logon, - "sso_enabled": core_settings.sso_enabled + "sso_enabled": core_settings.sso_enabled, } ) diff --git a/api/tacticalrmm/tacticalrmm/urls.py b/api/tacticalrmm/tacticalrmm/urls.py index e1f2cb56..3bc77d66 100644 --- a/api/tacticalrmm/tacticalrmm/urls.py +++ b/api/tacticalrmm/tacticalrmm/urls.py @@ -9,6 +9,7 @@ from ee.sso.urls import allauth_urls from core.consumers import DashInfo, TerminalConsumer from core.views import home + class AgentIDConverter: regex = "[^/]{20}[^/]+"