Skip to content

Commit 9aa070e

Browse files
authored
Merge pull request #44 from datum-cloud/43-phase-1-disable-idp-deletion-in-manage-idp-view
feat: make IDP unlinking configurable via env var
2 parents 4b9f265 + cf62890 commit 9aa070e

8 files changed

Lines changed: 40 additions & 24 deletions

File tree

apps/login/src/app/(main)/(boxed)/idp/link/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,10 @@ export default async function Page(props: {
163163
/>
164164
</h2>
165165
<ul className="space-y-2">
166-
<LinkedIdpList linkedIdps={linkedIdps} />
166+
<LinkedIdpList
167+
linkedIdps={linkedIdps}
168+
allowUnlink={process.env.ALLOW_IDP_UNLINK === "true"}
169+
/>
167170
</ul>
168171
</div>
169172
)}

apps/login/src/components/button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export const getButtonClasses = (
3535
color: ButtonColors,
3636
) =>
3737
clsx({
38-
"box-border font-normal text-button-foreground text-center justify-center leading-36px inline-flex items-center rounded-md focus:outline-none transition-colors transition-shadow duration-300":
39-
true,
38+
"box-border font-normal text-button-foreground text-center justify-center leading-36px inline-flex items-center rounded-md focus:outline-none transition-colors transition-shadow duration-300": true,
4039
"bg-button-primary-background text-button-primary-foreground disabled:opacity-60 disabled:cursor-not-allowed hover:opacity-90 focus:opacity-80 disabled:pointer-events-none transition-all":
4140
variant === ButtonVariants.Primary,
4241
"bg-button-ghost-background border-none shadow-none text-button-ghost-foreground underline hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed":

apps/login/src/components/input.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ export type TextInputProps = DetailedHTMLProps<
2727

2828
const styles = (error: boolean, disabled: boolean) =>
2929
clsx({
30-
"box-border flex flex-row items-center px-4 py-2 w-full bg-input-background border border-input-border rounded-md transition-colors duration-300 opacity-100":
31-
true,
32-
"focus:outline-none focus:ring-0 focus:border-input-focus focus:!shadow-[0_0_0_2px_rgba(77,99,86,0.15)] text-input-foreground placeholder:text-input-foreground placeholder:opacity-60":
33-
true,
30+
"box-border flex flex-row items-center px-4 py-2 w-full bg-input-background border border-input-border rounded-md transition-colors duration-300 opacity-100": true,
31+
"focus:outline-none focus:ring-0 focus:border-input-focus focus:!shadow-[0_0_0_2px_rgba(77,99,86,0.15)] text-input-foreground placeholder:text-input-foreground placeholder:opacity-60": true,
3432
"border-warn-light-500 dark:border-warn-dark-500 hover:border-warn-light-500 hover:dark:border-warn-dark-500 focus:border-warn-light-500 focus:dark:border-warn-dark-500":
3533
error,
3634
"pointer-events-none opacity-50 cursor-default": disabled,

apps/login/src/components/linked-idp-list.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ export type LinkedIdp = {
1515

1616
type Props = {
1717
linkedIdps: LinkedIdp[];
18+
allowUnlink?: boolean;
1819
};
1920

20-
export function LinkedIdpList({ linkedIdps }: Props) {
21+
export function LinkedIdpList({ linkedIdps, allowUnlink = false }: Props) {
2122
return (
2223
<ul className="space-y-2 w-full">
2324
{linkedIdps.map((l) => {
@@ -88,15 +89,17 @@ export function LinkedIdpList({ linkedIdps }: Props) {
8889
</div>
8990
</div>
9091

91-
<div className="shrink-0">
92-
<UnlinkIdpButton
93-
unlinkAction={unlinkIdp}
94-
idpId={l.idpId}
95-
linkedUserId={l.linkedUserId}
96-
providerName={l.idpName}
97-
isLastIdp={linkedIdps.length === 1}
98-
/>
99-
</div>
92+
{allowUnlink && (
93+
<div className="shrink-0">
94+
<UnlinkIdpButton
95+
unlinkAction={unlinkIdp}
96+
idpId={l.idpId}
97+
linkedUserId={l.linkedUserId}
98+
providerName={l.idpName}
99+
isLastIdp={linkedIdps.length === 1}
100+
/>
101+
</div>
102+
)}
100103
</li>
101104
);
102105
})}

apps/login/src/components/state-badge.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ export type StateBadgeProps = {
1616

1717
const getBadgeClasses = (state: BadgeState, evenPadding: boolean) =>
1818
clsx({
19-
"w-fit border-box h-18 w-18 flex flex-row items-center whitespace-nowrap tracking-wider leading-4 items-center justify-center px-2 py-2px text-12px rounded-full shadow-sm":
20-
true,
19+
"w-fit border-box h-18 w-18 flex flex-row items-center whitespace-nowrap tracking-wider leading-4 items-center justify-center px-2 py-2px text-12px rounded-full shadow-sm": true,
2120
"bg-state-success-light-background text-state-success-light-color dark:bg-state-success-dark-background dark:text-state-success-dark-color ":
2221
state === BadgeState.Success,
2322
"bg-state-neutral-light-background text-state-neutral-light-color dark:bg-state-neutral-dark-background dark:text-state-neutral-dark-color":

apps/login/src/lib/server/idp.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ export async function createNewSessionForLDAP(
273273
}
274274

275275
export async function unlinkIdp(formData: FormData) {
276+
if (process.env.ALLOW_IDP_UNLINK !== "true") {
277+
console.warn("Attempt to unlink IDP while feature is disabled");
278+
return;
279+
}
280+
276281
const _headers = await headers();
277282
const { serviceUrl } = getServiceUrlFromHeaders(_headers);
278283

config/base/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ spec:
3838
env:
3939
- name: ZITADEL_API_URL
4040
value: https://auth.datum.net
41+
- name: ALLOW_IDP_UNLINK
42+
value: "false"
4143
envFrom:
4244
# Add secret for ZITADEL_SERVICE_USER_TOKEN
4345
- secretRef:

turbo.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
22
"$schema": "https://turbo.build/schema.json",
33
"ui": "tui",
4-
"globalDependencies": ["**/.env.*local"],
4+
"globalDependencies": [
5+
"**/.env.*local"
6+
],
57
"globalEnv": [
68
"DEBUG",
79
"VERCEL_URL",
@@ -16,7 +18,8 @@
1618
"ENABLE_ZITADEL_API_TRANSLATION",
1719
"NODE_ENV",
1820
"MARKER_IO_PROJECT_ID",
19-
"FATHOM_ID"
21+
"FATHOM_ID",
22+
"ALLOW_IDP_UNLINK"
2023
],
2124
"tasks": {
2225
"generate": {
@@ -32,11 +35,15 @@
3235
"test:unit:standalone": {},
3336
"test:integration": {},
3437
"test:integration:setup": {
35-
"with": ["dev"]
38+
"with": [
39+
"dev"
40+
]
3641
},
3742
"test:acceptance:setup": {},
3843
"test:acceptance:setup:dev": {
39-
"with": ["dev"]
44+
"with": [
45+
"dev"
46+
]
4047
},
4148
"test:watch": {
4249
"persistent": true
@@ -51,4 +58,4 @@
5158
"cache": false
5259
}
5360
}
54-
}
61+
}

0 commit comments

Comments
 (0)