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}[^/]+"