Skip to content

Commit b06cb0e

Browse files
authored
Add a settings page for custom IdP and MFA (#308)
1 parent 0c924f7 commit b06cb0e

File tree

1 file changed

+145
-4
lines changed

1 file changed

+145
-4
lines changed

src/views/Settings.tsx

Lines changed: 145 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import { actions as routeActions } from "../store/route";
5050
import { actions as userActions } from "../store/user";
5151
import {useOidc} from "@axa-fr/react-oidc";
5252
import {getConfig} from "../config";
53+
import {Link} from "react-router-dom";
5354

5455
const { Title, Paragraph, Text } = Typography;
5556

@@ -76,6 +77,7 @@ export const Settings = () => {
7677
];
7778

7879
const [groupsClicked, setGroupsClicked] = useState(false);
80+
const [idpCLicked, setIdpClicked] = useState(false);
7981
const [billingClicked, setBillingClicked] = useState(false);
8082
const [authClicked, setAuthClicked] = useState(true);
8183
const [dangerClicked, setDangerClicked] = useState(false);
@@ -657,24 +659,35 @@ export const Settings = () => {
657659
setGroupsClicked(false);
658660
setBillingClicked(false);
659661
setDangerClicked(false);
662+
setIdpClicked(false);
660663
break;
661664
case "groups":
662665
setGroupsClicked(true);
663666
setBillingClicked(false);
664667
setAuthClicked(false);
665668
setDangerClicked(false);
669+
setIdpClicked(false);
666670
break;
667671
case "billing":
668672
setBillingClicked(true);
669673
setAuthClicked(false);
670674
setGroupsClicked(false);
671675
setDangerClicked(false);
676+
setIdpClicked(false);
672677
break;
673678
case "danger":
674679
setBillingClicked(false);
675680
setAuthClicked(false);
676681
setGroupsClicked(false);
677682
setDangerClicked(true);
683+
setIdpClicked(false);
684+
break;
685+
case "idp":
686+
setIdpClicked(true);
687+
setBillingClicked(false);
688+
setAuthClicked(false);
689+
setGroupsClicked(false);
690+
setDangerClicked(false);
678691
break;
679692
}
680693
};
@@ -702,12 +715,12 @@ export const Settings = () => {
702715
"System settings",
703716
"sub2",
704717
<SettingOutlined />,
705-
[getItem("Authentication", "auth"), getItem("Groups", "groups"), getItem("Danger zone", "danger", undefined, undefined, undefined, !isOwner)],
718+
[getItem("Authentication", "auth"), getItem("Groups", "groups"), getItem("Identity provider", "idp", undefined, undefined, undefined, !(isNetBirdHosted() || isLocalDev())), getItem("Danger zone", "danger", undefined, undefined, undefined, !isOwner)],
706719
"group"
707720
),
708721
];
709722

710-
useEffect(() => {}, [groupsClicked, billingClicked, authClicked, dangerClicked]);
723+
useEffect(() => {}, [groupsClicked, billingClicked, authClicked, dangerClicked, idpCLicked]);
711724
const renderGroupsSettingForm = () => {
712725
return(
713726
<>
@@ -1034,9 +1047,10 @@ export const Settings = () => {
10341047
/>
10351048
</Form.Item>
10361049
</div>
1050+
10371051
<Col
10381052
span={24}
1039-
style={{ marginTop: "10px", marginBottom: "24px" }}
1053+
style={{ marginTop: "-10px", marginBottom: "24px" }}
10401054
>
10411055
<Text type={"secondary"}>
10421056
Learn more about
@@ -1050,6 +1064,125 @@ export const Settings = () => {
10501064
</a>
10511065
</Text>
10521066
</Col>
1067+
{(isNetBirdHosted() || isLocalDev()) && (
1068+
<Col span={24}
1069+
style={{ marginTop: "10px", marginBottom: "24px" }}>
1070+
<label
1071+
style={{
1072+
color: "rgba(0, 0, 0, 0.88)",
1073+
fontSize: "14px",
1074+
fontWeight: "500",
1075+
}}
1076+
>
1077+
Multi-factor authentication (MFA)
1078+
</label>
1079+
<Paragraph
1080+
type={"secondary"}
1081+
style={{
1082+
marginTop: "-2",
1083+
fontWeight: "400",
1084+
marginBottom: "5px",
1085+
}}
1086+
>
1087+
<Text type={"secondary"}>
1088+
If your IdP supports MFA, it will work automatically with NetBird. Otherwise, contact us at
1089+
<a
1090+
target="_blank"
1091+
rel="noreferrer"
1092+
href="mailto:[email protected]"
1093+
>
1094+
{" "}
1095+
1096+
{" "}
1097+
</a>
1098+
to enable this feature
1099+
</Text>
1100+
</Paragraph>
1101+
</Col>)}
1102+
</>
1103+
)
1104+
}
1105+
1106+
const renderIdpSettingsForm = () => {
1107+
return (
1108+
<>
1109+
<div
1110+
style={{
1111+
color: "rgba(0, 0, 0, 0.88)",
1112+
fontWeight: "500",
1113+
fontSize: "18px",
1114+
marginBottom: "20px",
1115+
}}
1116+
>
1117+
Identity provider
1118+
</div>
1119+
<div >
1120+
1121+
<Row>
1122+
<Col span={24}>
1123+
<label
1124+
style={{
1125+
color: "rgba(0, 0, 0, 0.88)",
1126+
fontSize: "14px",
1127+
fontWeight: "500",
1128+
}}
1129+
>
1130+
User and group sync
1131+
</label>
1132+
<Paragraph
1133+
type={"secondary"}
1134+
style={{
1135+
marginTop: "-2",
1136+
fontWeight: "400",
1137+
marginBottom: "5px",
1138+
}}
1139+
>
1140+
Sync users and groups from your IdP to use them in access control
1141+
</Paragraph>
1142+
</Col>
1143+
</Row>
1144+
1145+
<Col span={24}
1146+
style={{ marginTop: "10px", marginBottom: "24px" }}>
1147+
<label
1148+
style={{
1149+
color: "rgba(0, 0, 0, 0.88)",
1150+
fontSize: "14px",
1151+
fontWeight: "500",
1152+
}}
1153+
>
1154+
Custom IdP
1155+
</label>
1156+
<Paragraph
1157+
type={"secondary"}
1158+
style={{
1159+
marginTop: "-2",
1160+
fontWeight: "400",
1161+
marginBottom: "5px",
1162+
}}
1163+
>
1164+
Configure your custom IdP like Okta or Jumpcloud
1165+
</Paragraph>
1166+
</Col>
1167+
1168+
<Col
1169+
span={24}
1170+
style={{ marginTop: "10px", marginBottom: "24px" }}
1171+
>
1172+
<Text type={"secondary"}>
1173+
To enable these features, please contact us at
1174+
<a
1175+
target="_blank"
1176+
rel="noreferrer"
1177+
href="mailto:[email protected]"
1178+
>
1179+
{" "}
1180+
1181+
</a>
1182+
</Text>
1183+
</Col>
1184+
</div>
1185+
10531186
</>
10541187
)
10551188
}
@@ -1125,6 +1258,9 @@ export const Settings = () => {
11251258
if (dangerClicked) {
11261259
loaded = renderDangerSettingsForm()
11271260
}
1261+
if (idpCLicked) {
1262+
loaded = renderIdpSettingsForm()
1263+
}
11281264

11291265
return (
11301266
<Form
@@ -1135,7 +1271,7 @@ export const Settings = () => {
11351271
>
11361272
<Card loading={loading} defaultValue={"Enabled"}>
11371273
{loaded}
1138-
{!dangerClicked && (<Form.Item style={{ marginBottom: "0" }}>
1274+
{!(dangerClicked || idpCLicked) && (<Form.Item style={{ marginBottom: "0" }}>
11391275
<Button type="primary" htmlType="submit">
11401276
Save
11411277
</Button>
@@ -1566,6 +1702,11 @@ export const Settings = () => {
15661702
<Col span={24}>{renderSettingForm()}</Col>
15671703
</Row>
15681704
)}
1705+
{idpCLicked && (
1706+
<Row style={{ marginTop: "0", width: "100%" }}>
1707+
<Col span={24}>{renderSettingForm()}</Col>
1708+
</Row>
1709+
)}
15691710
</Col>
15701711
</Row>
15711712
</Container>

0 commit comments

Comments
 (0)