Draft revamp org auth tab

This commit is contained in:
Tuan Dang
2024-03-12 09:37:28 -07:00
parent 635948c4f4
commit a6d7d32156
10 changed files with 165 additions and 139 deletions
@@ -17,9 +17,9 @@ export const getDefaultOnPremFeatures = () => {
customAlerts: false, customAlerts: false,
auditLogs: false, auditLogs: false,
auditLogsRetentionDays: 0, auditLogsRetentionDays: 0,
samlSSO: false, samlSSO: true,
scim: false, scim: true,
ldap: false, ldap: true,
status: null, status: null,
trial_end: null, trial_end: null,
has_used_trial: true, has_used_trial: true,
@@ -23,9 +23,9 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
customAlerts: false, customAlerts: false,
auditLogs: false, auditLogs: false,
auditLogsRetentionDays: 0, auditLogsRetentionDays: 0,
samlSSO: false, samlSSO: true,
scim: false, scim: true,
ldap: false, ldap: true,
status: null, status: null,
trial_end: null, trial_end: null,
has_used_trial: true, has_used_trial: true,
@@ -24,9 +24,9 @@ export type TFeatureSet = {
customAlerts: false; customAlerts: false;
auditLogs: false; auditLogs: false;
auditLogsRetentionDays: 0; auditLogsRetentionDays: 0;
samlSSO: false; samlSSO: true;
scim: false; scim: true;
ldap: false; ldap: true;
status: null; status: null;
trial_end: null; trial_end: null;
has_used_trial: true; has_used_trial: true;
@@ -7,7 +7,7 @@ export const OrgSettingsPage = () => {
return ( return (
<div className="flex justify-center bg-bunker-800 text-white w-full py-6"> <div className="flex justify-center bg-bunker-800 text-white w-full py-6">
<div className="max-w-7xl w-full px-6"> <div className="max-w-4xl w-full px-6">
<div className="mb-4"> <div className="mb-4">
<p className="text-3xl font-semibold text-gray-200">{t("settings.org.title")}</p> <p className="text-3xl font-semibold text-gray-200">{t("settings.org.title")}</p>
</div> </div>
@@ -9,7 +9,7 @@ import { OrgSSOSection } from "./OrgSSOSection";
export const OrgAuthTab = withPermission( export const OrgAuthTab = withPermission(
() => { () => {
return ( return (
<div> <div className="rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-6">
<OrgGeneralAuthSection /> <OrgGeneralAuthSection />
<OrgSSOSection /> <OrgSSOSection />
<OrgLDAPSection /> <OrgLDAPSection />
@@ -59,25 +59,44 @@ export const OrgGeneralAuthSection = () => {
} }
return ( return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <>
<h2 className="flex-1 text-xl font-semibold text-white mb-8">Settings</h2> <div className="py-4">
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}> <div className="mb-2 flex justify-between">
{(isAllowed) => ( <h3 className="text-md text-mineshaft-100">Allow users to send invites</h3>
<Switch <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
id="enforce-org-auth" {(isAllowed) => (
onCheckedChange={(value) => handleEnforceOrgAuthToggle(value)} <Switch
isChecked={currentOrg?.authEnforced ?? false} id="allow-org-invites"
isDisabled={!isAllowed} onCheckedChange={(value) => handleEnforceOrgAuthToggle(value)}
> isChecked={currentOrg?.authEnforced ?? false}
Enforce SAML SSO isDisabled={!isAllowed}
</Switch> />
)} )}
</OrgPermissionCan> </OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">Allow members to invite new users to this organization</p>
</div>
<div className="py-4">
<div className="mb-2 flex justify-between">
<h3 className="text-md text-mineshaft-100">Enforce SAML SSO</h3>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
<Switch
id="enforce-org-auth"
onCheckedChange={(value) => handleEnforceOrgAuthToggle(value)}
isChecked={currentOrg?.authEnforced ?? false}
isDisabled={!isAllowed}
/>
)}
</OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">Enforce members to authenticate via SAML to access this organization</p>
</div>
<UpgradePlanModal <UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen} isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)} onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text="You can enforce SAML SSO if you switch to Infisical's Pro plan." text="You can enforce SAML SSO if you switch to Infisical's Pro plan."
/> />
</div> </>
); );
} }
@@ -1,6 +1,3 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
import { import {
@@ -27,7 +24,7 @@ export const OrgLDAPSection = (): JSX.Element => {
const { currentOrg } = useOrganization(); const { currentOrg } = useOrganization();
const { subscription } = useSubscription(); const { subscription } = useSubscription();
const { createNotification } = useNotificationContext(); const { createNotification } = useNotificationContext();
const { data, isLoading } = useGetLDAPConfig(currentOrg?.id ?? ""); const { data } = useGetLDAPConfig(currentOrg?.id ?? "");
const { mutateAsync } = useUpdateLDAPConfig(); const { mutateAsync } = useUpdateLDAPConfig();
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([ const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
"addLDAP", "addLDAP",
@@ -88,50 +85,53 @@ export const OrgLDAPSection = (): JSX.Element => {
}; };
return ( return (
<div className="p-4 bg-mineshaft-900 mb-6 rounded-lg border border-mineshaft-600"> <>
<div className="flex items-center mb-8"> <hr className="border-mineshaft-600" />
<h2 className="text-xl font-semibold flex-1 text-white">LDAP</h2> <div className="py-4">
{!isLoading && ( <div className="mb-2 flex items-center justify-between">
<h2 className="text-md text-mineshaft-100">LDAP</h2>
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Ldap}> <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Ldap}>
{(isAllowed) => ( {(isAllowed) => (
<Button <Button
onClick={addLDAPBtnClick} onClick={addLDAPBtnClick}
colorSchema="secondary" colorSchema="secondary"
isDisabled={!isAllowed} isDisabled={!isAllowed}
leftIcon={<FontAwesomeIcon icon={faPlus} />}
> >
Configure Manage
</Button> </Button>
)} )}
</OrgPermissionCan> </OrgPermissionCan>
)}
</div>
{data && (
<div className="mb-4">
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Ldap}>
{(isAllowed) => (
<Switch
id="enable-saml-sso"
onCheckedChange={(value) => handleLDAPToggle(value)}
isChecked={data ? data.isActive : false}
isDisabled={!isAllowed}
>
Enable
</Switch>
)}
</OrgPermissionCan>
</div> </div>
)} <p className="text-sm text-mineshaft-300">Manage LDAP authentication configuration</p>
<LDAPModal </div>
popUp={popUp} <div className="py-4">
handlePopUpClose={handlePopUpClose} <div className="mb-2 flex items-center justify-between">
handlePopUpToggle={handlePopUpToggle} <h2 className="text-md text-mineshaft-100">Enable LDAP</h2>
/> <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Ldap}>
<UpgradePlanModal {(isAllowed) => (
isOpen={popUp.upgradePlan.isOpen} <Switch
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)} id="enable-saml-sso"
text="You can use LDAP authentication if you switch to Infisical's Enterprise plan." onCheckedChange={(value) => handleLDAPToggle(value)}
/> isChecked={data ? data.isActive : false}
</div> isDisabled={!isAllowed}
>
Enable
</Switch>
)}
</OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">Allow members to authenticate into Infisical with LDAP</p>
</div>
<LDAPModal
popUp={popUp}
handlePopUpClose={handlePopUpClose}
handlePopUpToggle={handlePopUpToggle}
/>
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text="You can use LDAP authentication if you switch to Infisical's Enterprise plan."
/>
</>
); );
}; };
@@ -1,6 +1,3 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
import { import {
@@ -64,40 +61,47 @@ export const OrgScimSection = () => {
} }
return ( return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <>
<div className="mb-8 flex items-center"> <hr className="border-mineshaft-600" />
<h2 className="flex-1 text-xl font-semibold text-white">SCIM</h2> <div className="py-4">
<OrgPermissionCan I={OrgPermissionActions.Read} a={OrgPermissionSubjects.Scim}> <div className="mb-2 flex justify-between items-center">
<h2 className="text-md text-mineshaft-100">SCIM</h2>
<OrgPermissionCan I={OrgPermissionActions.Read} a={OrgPermissionSubjects.Scim}>
{(isAllowed) => ( {(isAllowed) => (
<Button <Button
onClick={addScimTokenBtnClick} onClick={addScimTokenBtnClick}
colorSchema="secondary" colorSchema="secondary"
isDisabled={!isAllowed} isDisabled={!isAllowed}
leftIcon={<FontAwesomeIcon icon={faPlus} />}
> >
Configure Manage
</Button> </Button>
)} )}
</OrgPermissionCan> </OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">Manage SCIM configuration</p>
</div>
<div className="py-4">
<div className="mb-2 flex justify-between items-center">
<h2 className="text-md text-mineshaft-100">Enable SCIM</h2>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Scim}>
{(isAllowed) => (
<Switch
id="enable-scim"
onCheckedChange={(value) => {
if (subscription?.scim) {
handleEnableSCIMToggle(value)
} else {
handlePopUpOpen("upgradePlan");
}
}}
isChecked={currentOrg?.scimEnabled ?? false}
isDisabled={!isAllowed}
/>
)}
</OrgPermissionCan>
</div>
<p className="text-sm text-mineshaft-300">Allow member provisioning/deprovisioning with SCIM</p>
</div> </div>
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Scim}>
{(isAllowed) => (
<Switch
id="enable-scim"
onCheckedChange={(value) => {
if (subscription?.scim) {
handleEnableSCIMToggle(value)
} else {
handlePopUpOpen("upgradePlan");
}
}}
isChecked={currentOrg?.scimEnabled ?? false}
isDisabled={!isAllowed}
>
Enable
</Switch>
)}
</OrgPermissionCan>
<ScimTokenModal <ScimTokenModal
popUp={popUp} popUp={popUp}
handlePopUpOpen={handlePopUpOpen} handlePopUpOpen={handlePopUpOpen}
@@ -108,6 +112,6 @@ export const OrgScimSection = () => {
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)} onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text="You can use SCIM Provisioning if you switch to Infisical's Enterprise plan." text="You can use SCIM Provisioning if you switch to Infisical's Enterprise plan."
/> />
</div> </>
); );
} }
@@ -1,6 +1,3 @@
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider"; import { useNotificationContext } from "@app/components/context/Notifications/NotificationProvider";
import { OrgPermissionCan } from "@app/components/permissions"; import { OrgPermissionCan } from "@app/components/permissions";
import { Button, Switch, UpgradePlanModal } from "@app/components/v2"; import { Button, Switch, UpgradePlanModal } from "@app/components/v2";
@@ -81,49 +78,55 @@ export const OrgSSOSection = (): JSX.Element => {
}; };
return ( return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <>
<div className="mb-8 flex items-center"> <hr className="border-mineshaft-600" />
<h2 className="flex-1 text-xl font-semibold text-white">SAML</h2> <div className="py-4">
{!isLoading && ( <div className="mb-2 flex items-center justify-between">
<OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Sso}> <h2 className="text-md text-mineshaft-100">SAML</h2>
{(isAllowed) => ( {!isLoading && (
<Button <OrgPermissionCan I={OrgPermissionActions.Create} a={OrgPermissionSubjects.Sso}>
onClick={addSSOBtnClick} {(isAllowed) => (
colorSchema="secondary" <Button
isDisabled={!isAllowed} onClick={addSSOBtnClick}
leftIcon={<FontAwesomeIcon icon={faPlus} />} colorSchema="secondary"
> isDisabled={!isAllowed}
Configure >
</Button> Manage
)} </Button>
</OrgPermissionCan> )}
)} </OrgPermissionCan>
</div> )}
{/* {data && ( */}
<div className="mb-4">
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
{(isAllowed) => (
<Switch
id="enable-saml-sso"
onCheckedChange={(value) => handleSamlSSOToggle(value)}
isChecked={data ? data.isActive : false}
isDisabled={!isAllowed}
>
Enable
</Switch>
)}
</OrgPermissionCan>
</div> </div>
<SSOModal <p className="text-sm text-mineshaft-300">Manage SAML authentication configuration</p>
popUp={popUp} </div>
handlePopUpClose={handlePopUpClose} <div className="py-4">
handlePopUpToggle={handlePopUpToggle} <div className="mb-2 flex items-center justify-between">
/> <h2 className="text-md text-mineshaft-100">Enable SAML</h2>
<UpgradePlanModal {!isLoading && (
isOpen={popUp.upgradePlan.isOpen} <OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Sso}>
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)} {(isAllowed) => (
text="You can use SAML SSO if you switch to Infisical's Pro plan." <Switch
/> id="enable-saml-sso"
</div> onCheckedChange={(value) => handleSamlSSOToggle(value)}
isChecked={data ? data.isActive : false}
isDisabled={!isAllowed}
/>
)}
</OrgPermissionCan>
)}
</div>
<p className="text-sm text-mineshaft-300">Allow members to authenticate into Infisical with SAML</p>
</div>
<SSOModal
popUp={popUp}
handlePopUpClose={handlePopUpClose}
handlePopUpToggle={handlePopUpToggle}
/>
<UpgradePlanModal
isOpen={popUp.upgradePlan.isOpen}
onOpenChange={(isOpen) => handlePopUpToggle("upgradePlan", isOpen)}
text="You can use SAML SSO if you switch to Infisical's Pro plan."
/>
</>
); );
}; };
@@ -6,7 +6,7 @@ import { OrgGeneralTab } from "../OrgGeneralTab";
const tabs = [ const tabs = [
{ name: "General", key: "tab-org-general" }, { name: "General", key: "tab-org-general" },
{ name: "Authentication", key: "tab-org-auth" } { name: "Security", key: "tab-org-security" }
]; ];
export const OrgTabGroup = () => { export const OrgTabGroup = () => {
return ( return (