From 069b0cd6fbd8bf163f1404c3b3d6c22275d3357e Mon Sep 17 00:00:00 2001 From: Tuan Dang Date: Fri, 9 Feb 2024 10:02:12 -0800 Subject: [PATCH] Fix lint issue, add backend permission check for SAML SSO enforcement toggle --- backend/src/services/org/org-service.ts | 4 ++++ .../components/OrgAuthTab/OrgGeneralAuthSection.tsx | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/src/services/org/org-service.ts b/backend/src/services/org/org-service.ts index 8b333316f..7fafca438 100644 --- a/backend/src/services/org/org-service.ts +++ b/backend/src/services/org/org-service.ts @@ -131,6 +131,10 @@ export const orgServiceFactory = ({ const { permission } = await permissionService.getOrgPermission(actor, actorId, orgId, actorOrgId); ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Settings); + if (authEnforced !== undefined) { + ForbiddenError.from(permission).throwUnlessCan(OrgPermissionActions.Edit, OrgPermissionSubjects.Sso); + } + if (authEnforced) { const samlCfg = await samlConfigDAL.findEnforceableSamlCfg(orgId); if (!samlCfg) diff --git a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx index 80fd890a1..9bc026cf8 100644 --- a/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx +++ b/frontend/src/views/Settings/OrgSettingsPage/components/OrgAuthTab/OrgGeneralAuthSection.tsx @@ -34,7 +34,6 @@ export const OrgGeneralAuthSection = () => { await logout.mutateAsync(); window.open(`/api/v1/sso/redirect/saml2/organizations/${currentOrg.slug}`); window.close(); - return; } } catch (err) {