Skip to content

Commit 4c91146

Browse files
authored
fix: hide OIDC and Github auth settings when they are disabled (#9447)
1 parent 8f3b407 commit 4c91146

File tree

3 files changed

+109
-103
lines changed

3 files changed

+109
-103
lines changed

site/src/components/DeploySettingsLayout/OptionsTable.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
OptionValue,
1313
} from "components/DeploySettingsLayout/Option"
1414
import { FC } from "react"
15-
import { DisabledBadge } from "./Badges"
1615
import { intervalToDuration, formatDuration } from "date-fns"
1716

1817
const OptionsTable: FC<{
@@ -21,7 +20,7 @@ const OptionsTable: FC<{
2120
const styles = useStyles()
2221

2322
if (options.length === 0) {
24-
return <DisabledBadge></DisabledBadge>
23+
return <p>No options to configure</p>
2524
}
2625

2726
return (

site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.tsx

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -23,66 +23,70 @@ export const SecuritySettingsPageView = ({
2323
options: options,
2424
featureAuditLogEnabled,
2525
featureBrowserOnlyEnabled,
26-
}: SecuritySettingsPageViewProps): JSX.Element => (
27-
<>
28-
<Stack direction="column" spacing={6}>
29-
<div>
30-
<Header
31-
title="Security"
32-
description="Ensure your Coder deployment is secure."
33-
/>
26+
}: SecuritySettingsPageViewProps): JSX.Element => {
27+
const tlsOptions = options.filter((o) =>
28+
deploymentGroupHasParent(o.group, "TLS"),
29+
)
3430

35-
<OptionsTable
36-
options={useDeploymentOptions(
37-
options,
38-
"SSH Keygen Algorithm",
39-
"Secure Auth Cookie",
40-
"Disable Owner Workspace Access",
41-
)}
42-
/>
43-
</div>
31+
return (
32+
<>
33+
<Stack direction="column" spacing={6}>
34+
<div>
35+
<Header
36+
title="Security"
37+
description="Ensure your Coder deployment is secure."
38+
/>
4439

45-
<div>
46-
<Header
47-
title="Audit Logging"
48-
secondary
49-
description="Allow auditors to monitor user operations in your deployment."
50-
docsHref={docs("/admin/audit-logs")}
51-
/>
40+
<OptionsTable
41+
options={useDeploymentOptions(
42+
options,
43+
"SSH Keygen Algorithm",
44+
"Secure Auth Cookie",
45+
"Disable Owner Workspace Access",
46+
)}
47+
/>
48+
</div>
5249

53-
<Badges>
54-
{featureAuditLogEnabled ? <EnabledBadge /> : <DisabledBadge />}
55-
<EnterpriseBadge />
56-
</Badges>
57-
</div>
50+
<div>
51+
<Header
52+
title="Audit Logging"
53+
secondary
54+
description="Allow auditors to monitor user operations in your deployment."
55+
docsHref={docs("/admin/audit-logs")}
56+
/>
5857

59-
<div>
60-
<Header
61-
title="Browser Only Connections"
62-
secondary
63-
description="Block all workspace access via SSH, port forward, and other non-browser connections."
64-
docsHref={docs("/networking#browser-only-connections-enterprise")}
65-
/>
58+
<Badges>
59+
{featureAuditLogEnabled ? <EnabledBadge /> : <DisabledBadge />}
60+
<EnterpriseBadge />
61+
</Badges>
62+
</div>
6663

67-
<Badges>
68-
{featureBrowserOnlyEnabled ? <EnabledBadge /> : <DisabledBadge />}
69-
<EnterpriseBadge />
70-
</Badges>
71-
</div>
64+
<div>
65+
<Header
66+
title="Browser Only Connections"
67+
secondary
68+
description="Block all workspace access via SSH, port forward, and other non-browser connections."
69+
docsHref={docs("/networking#browser-only-connections-enterprise")}
70+
/>
7271

73-
<div>
74-
<Header
75-
title="TLS"
76-
secondary
77-
description="Ensure TLS is properly configured for your Coder deployment."
78-
/>
72+
<Badges>
73+
{featureBrowserOnlyEnabled ? <EnabledBadge /> : <DisabledBadge />}
74+
<EnterpriseBadge />
75+
</Badges>
76+
</div>
7977

80-
<OptionsTable
81-
options={options.filter((o) =>
82-
deploymentGroupHasParent(o.group, "TLS"),
83-
)}
84-
/>
85-
</div>
86-
</Stack>
87-
</>
88-
)
78+
{tlsOptions.length > 0 && (
79+
<div>
80+
<Header
81+
title="TLS"
82+
secondary
83+
description="Ensure TLS is properly configured for your Coder deployment."
84+
/>
85+
86+
<OptionsTable options={tlsOptions} />
87+
</div>
88+
)}
89+
</Stack>
90+
</>
91+
)
92+
}

site/src/pages/DeploySettingsPage/UserAuthSettingsPage/UserAuthSettingsPageView.tsx

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -19,56 +19,59 @@ export type UserAuthSettingsPageViewProps = {
1919

2020
export const UserAuthSettingsPageView = ({
2121
options,
22-
}: UserAuthSettingsPageViewProps): JSX.Element => (
23-
<>
24-
<Stack direction="column" spacing={6}>
25-
<div>
26-
<Header title="User Authentication" />
22+
}: UserAuthSettingsPageViewProps): JSX.Element => {
23+
const oidcEnabled = Boolean(
24+
useDeploymentOptions(options, "OIDC Client ID")[0].value,
25+
)
26+
const githubEnabled = Boolean(
27+
useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value,
28+
)
2729

28-
<Header
29-
title="Login with OpenID Connect"
30-
secondary
31-
description="Set up authentication to login with OpenID Connect."
32-
docsHref={docs("/admin/auth#openid-connect-with-google")}
33-
/>
30+
return (
31+
<>
32+
<Stack direction="column" spacing={6}>
33+
<div>
34+
<Header title="User Authentication" />
3435

35-
<Badges>
36-
{useDeploymentOptions(options, "OIDC Client ID")[0].value ? (
37-
<EnabledBadge />
38-
) : (
39-
<DisabledBadge />
40-
)}
41-
</Badges>
36+
<Header
37+
title="Login with OpenID Connect"
38+
secondary
39+
description="Set up authentication to login with OpenID Connect."
40+
docsHref={docs("/admin/auth#openid-connect-with-google")}
41+
/>
42+
43+
<Badges>{oidcEnabled ? <EnabledBadge /> : <DisabledBadge />}</Badges>
4244

43-
<OptionsTable
44-
options={options.filter((o) =>
45-
deploymentGroupHasParent(o.group, "OIDC"),
45+
{oidcEnabled && (
46+
<OptionsTable
47+
options={options.filter((o) =>
48+
deploymentGroupHasParent(o.group, "OIDC"),
49+
)}
50+
/>
4651
)}
47-
/>
48-
</div>
52+
</div>
4953

50-
<div>
51-
<Header
52-
title="Login with GitHub"
53-
secondary
54-
description="Set up authentication to login with GitHub."
55-
docsHref={docs("/admin/auth#github")}
56-
/>
54+
<div>
55+
<Header
56+
title="Login with GitHub"
57+
secondary
58+
description="Set up authentication to login with GitHub."
59+
docsHref={docs("/admin/auth#github")}
60+
/>
5761

58-
<Badges>
59-
{useDeploymentOptions(options, "OAuth2 GitHub Client ID")[0].value ? (
60-
<EnabledBadge />
61-
) : (
62-
<DisabledBadge />
63-
)}
64-
</Badges>
62+
<Badges>
63+
{githubEnabled ? <EnabledBadge /> : <DisabledBadge />}
64+
</Badges>
6565

66-
<OptionsTable
67-
options={options.filter((o) =>
68-
deploymentGroupHasParent(o.group, "GitHub"),
66+
{githubEnabled && (
67+
<OptionsTable
68+
options={options.filter((o) =>
69+
deploymentGroupHasParent(o.group, "GitHub"),
70+
)}
71+
/>
6972
)}
70-
/>
71-
</div>
72-
</Stack>
73-
</>
74-
)
73+
</div>
74+
</Stack>
75+
</>
76+
)
77+
}

0 commit comments

Comments
 (0)