Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement: refactor access token fields to shared component, adjust all tooltip sizes and text formatting, and select positions

Scott Wilson93e8c2db1992
diff --git a/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx b/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx
index 6e01b0236b..148393a5e9 100644
--- a/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx
+++ b/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx
@@ -42,7 +42,7 @@ function TooltipContent({
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
- "z-[70] w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-sm bg-border px-3 py-1.5 text-xs text-balance text-foreground fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
+ "z-[70] w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-sm bg-border px-3 py-1.5 text-xs text-pretty text-foreground fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
className
)}
{...props}
diff --git a/frontend/src/helpers/identityAuthSchemas.ts b/frontend/src/helpers/identityAuthSchemas.ts
index 735ba583ba..bc2b811de6 100644
--- a/frontend/src/helpers/identityAuthSchemas.ts
+++ b/frontend/src/helpers/identityAuthSchemas.ts
@@ -17,6 +17,24 @@ export const accessTokenTtlSchema = (maxTTL: number, label: string) =>
message: `${label} cannot exceed ${Math.floor(maxTTL / SECONDS_PER_DAY)} days`
});
+// Cross-field check mirroring the backend rule: a max TTL of 0 means "no maximum",
+// so the TTL is only constrained when a positive max TTL is set.
+export const superRefineAccessTokenTtl = (
+ data: { accessTokenTTL?: string; accessTokenMaxTTL?: string },
+ ctx: z.RefinementCtx
+) => {
+ const ttl = Number(data.accessTokenTTL);
+ const maxTtl = Number(data.accessTokenMaxTTL);
+
+ if (!Number.isNaN(ttl) && !Number.isNaN(maxTtl) && maxTtl > 0 && ttl > maxTtl) {
+ ctx.addIssue({
+ code: z.ZodIssueCode.custom,
+ message: "Access Token TTL cannot be greater than Access Token Max TTL",
+ path: ["accessTokenTTL"]
+ });
+ }
+};
+
// Trusted-IP constraint fields shared by every identity auth method form
// (access token trusted IPs, plus client secret trusted IPs for Universal Auth).
export const trustedIpsSchema = z
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx
index 3934c6186f..64d9bceee8 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAliCloudAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -22,11 +21,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -37,6 +36,7 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -49,7 +49,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenNumUsesLimit: z.string(),
accessTokenTrustedIps: trustedIpsSchema
})
- .required();
+ .required()
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -176,8 +177,6 @@ export const IdentityAliCloudAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -212,50 +211,7 @@ export const IdentityAliCloudAuthForm = ({
</Field>
)}
/>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -271,7 +227,7 @@ export const IdentityAliCloudAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
index 60d0e4190e..19ec108382 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAwsAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -22,11 +21,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -37,6 +36,7 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -51,7 +51,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenNumUsesLimit: z.string(),
accessTokenTrustedIps: trustedIpsSchema
})
- .required();
+ .required()
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -188,8 +189,6 @@ export const IdentityAwsAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -260,50 +259,7 @@ export const IdentityAwsAuthForm = ({
</Field>
)}
/>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -319,7 +275,7 @@ export const IdentityAwsAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
index 29a773b950..35c5b8ef31 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityAzureAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -22,11 +21,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -37,6 +36,7 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -51,7 +51,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenNumUsesLimit: z.string(),
accessTokenTrustedIps: trustedIpsSchema
})
- .required();
+ .required()
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -191,8 +192,6 @@ export const IdentityAzureAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -263,50 +262,7 @@ export const IdentityAzureAuthForm = ({
</Field>
)}
/>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -322,7 +278,7 @@ export const IdentityAzureAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
index 2135af6501..15a40a925b 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityGcpAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -27,11 +26,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -42,6 +41,7 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -57,7 +57,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenNumUsesLimit: z.string(),
accessTokenTrustedIps: trustedIpsSchema
})
- .required();
+ .required()
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -204,8 +205,6 @@ export const IdentityGcpAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -234,7 +233,7 @@ export const IdentityGcpAuthForm = ({
<SelectTrigger id="gcp-auth-type" className="w-full" isError={Boolean(error)}>
<SelectValue placeholder="Select type" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value="gce" key="gce">
GCP ID Token Auth (Recommended)
</SelectItem>
@@ -303,50 +302,7 @@ export const IdentityGcpAuthForm = ({
)}
/>
)}
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -362,7 +318,7 @@ export const IdentityGcpAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
index 9fbeee5e5f..6450747921 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityJwtAuthForm.tsx
@@ -10,7 +10,6 @@ import { BashGlobPatternTooltip } from "@app/components/permissions";
import {
Button,
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -31,11 +30,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -44,6 +43,7 @@ import { IdentityJwtConfigurationType } from "@app/hooks/api/identities/enums";
import { useGetIdentityJwtAuth } from "@app/hooks/api/identities/queries";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -64,34 +64,36 @@ const buildSchema = (maxAccessTokenTTL: number) => {
boundSubject: z.string().optional().default("")
});
- return z.discriminatedUnion("configurationType", [
- z
- .object({
- configurationType: z.literal(IdentityJwtConfigurationType.JWKS),
- jwksUrl: z.string().trim().url(),
- jwksCaCert: z.string().trim().default(""),
- publicKeys: z
- .object({
- value: z.string()
- })
- .array()
- .optional()
- })
- .merge(common),
- z
- .object({
- configurationType: z.literal(IdentityJwtConfigurationType.STATIC),
- jwksUrl: z.string().trim().optional(),
- jwksCaCert: z.string().trim().optional().default(""),
- publicKeys: z
- .object({
- value: z.string().min(1)
- })
- .array()
- .min(1)
- })
- .merge(common)
- ]);
+ return z
+ .discriminatedUnion("configurationType", [
+ z
+ .object({
+ configurationType: z.literal(IdentityJwtConfigurationType.JWKS),
+ jwksUrl: z.string().trim().url(),
+ jwksCaCert: z.string().trim().default(""),
+ publicKeys: z
+ .object({
+ value: z.string()
+ })
+ .array()
+ .optional()
+ })
+ .merge(common),
+ z
+ .object({
+ configurationType: z.literal(IdentityJwtConfigurationType.STATIC),
+ jwksUrl: z.string().trim().optional(),
+ jwksCaCert: z.string().trim().optional().default(""),
+ publicKeys: z
+ .object({
+ value: z.string().min(1)
+ })
+ .array()
+ .min(1)
+ })
+ .merge(common)
+ ])
+ .superRefine(superRefineAccessTokenTtl);
};
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -281,8 +283,6 @@ export const IdentityJwtAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -331,7 +331,7 @@ export const IdentityJwtAuthForm = ({
>
<SelectValue placeholder="Select configuration type" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value={IdentityJwtConfigurationType.JWKS} key="jwks">
JWKS
</SelectItem>
@@ -393,7 +393,7 @@ export const IdentityJwtAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent className="text-center">
+ <TooltipContent className="max-w-md text-center">
This field only accepts PEM-formatted public keys
</TooltipContent>
</Tooltip>
@@ -467,7 +467,7 @@ export const IdentityJwtAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<BashGlobPatternTooltip />
</TooltipContent>
</Tooltip>
@@ -488,7 +488,7 @@ export const IdentityJwtAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<BashGlobPatternTooltip />
</TooltipContent>
</Tooltip>
@@ -522,7 +522,7 @@ export const IdentityJwtAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<BashGlobPatternTooltip />
</TooltipContent>
</Tooltip>
@@ -588,50 +588,7 @@ export const IdentityJwtAuthForm = ({
Add Claims
</Button>
</div>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -647,7 +604,7 @@ export const IdentityJwtAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
index 5294a4eb3b..7df024e5c1 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityKubernetesAuthForm.tsx
@@ -10,7 +10,6 @@ import { OrgPermissionCan } from "@app/components/permissions";
import {
Button,
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -36,11 +35,11 @@ import {
OrgGatewayPermissionActions,
OrgPermissionSubjects
} from "@app/context/OrgPermissionContext/types";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -59,6 +58,7 @@ import { VaultKubernetesAuthRole } from "@app/hooks/api/migration/types";
import { useCanUseOrgAppConnectionImport } from "@app/hooks/useCanUseAppConnectionImport";
import { usePopUp, UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
import { VaultKubernetesAuthImportModal } from "./VaultKubernetesAuthImportModal";
@@ -132,7 +132,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
"TLS certificate verification cannot be disabled while a CA certificate is provided. Either remove the CA certificate or enable verification."
});
}
- });
+ })
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -429,7 +430,6 @@ export const IdentityKubernetesAuthForm = ({
};
const tokenReviewMode = watch("tokenReviewMode");
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
return (
<form
@@ -484,7 +484,7 @@ export const IdentityKubernetesAuthForm = ({
</span>
</TooltipTrigger>
{!canUseAppConnectionImport && (
- <TooltipContent>
+ <TooltipContent className="max-w-md">
You don&apos;t have permission to import configurations from HashiCorp Vault
</TooltipContent>
)}
@@ -532,7 +532,7 @@ export const IdentityKubernetesAuthForm = ({
</div>
</TooltipTrigger>
{!isAllowed && (
- <TooltipContent>
+ <TooltipContent className="max-w-md">
Restricted access. You don&apos;t have permission to attach gateways
to resources.
</TooltipContent>
@@ -572,7 +572,7 @@ export const IdentityKubernetesAuthForm = ({
<SelectTrigger id="tokenReviewMode" isError={Boolean(error)}>
<SelectValue placeholder="Select review mode" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value="gateway">Gateway as Reviewer</SelectItem>
<SelectItem value="api">Manual Token Reviewer JWT (API)</SelectItem>
</SelectContent>
@@ -597,7 +597,7 @@ export const IdentityKubernetesAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The host string, host:port pair, or URL to the base of the Kubernetes API
server. This can usually be obtained by running &apos;kubectl
cluster-info&apos;
@@ -671,7 +671,7 @@ export const IdentityKubernetesAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<div className="flex flex-col gap-1">
<p>
A comma-separated list of trusted namespaces that service accounts must
@@ -714,7 +714,7 @@ export const IdentityKubernetesAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<div className="flex flex-col gap-1">
<p>
An optional comma-separated list of trusted service account names that
@@ -745,73 +745,7 @@ export const IdentityKubernetesAuthForm = ({
</Field>
)}
/>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL" className="inline-flex items-center gap-1.5">
- Access Token TTL (seconds)
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent>
- The lifetime for an acccess token in seconds. This value will be referenced
- at renewal time.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel
- htmlFor="accessTokenMaxTTL"
- className="inline-flex items-center gap-1.5"
- >
- Access Token Max TTL (seconds)
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent>
- The maximum lifetime for an access token in seconds. This value will be
- referenced at renewal time.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -827,7 +761,7 @@ export const IdentityKubernetesAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
@@ -865,7 +799,7 @@ export const IdentityKubernetesAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
An optional audience claim that the service account JWT token must have to
authenticate with Infisical. Leave empty to allow any audience claim.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
index a4416c6203..2bf0f52812 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityLdapAuthForm.tsx
@@ -10,7 +10,6 @@ import { createNotification } from "@app/components/notifications";
import {
Button,
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -35,11 +34,12 @@ import {
OrgPermissionMachineIdentityAuthTemplateActions,
OrgPermissionSubjects
} from "@app/context/OrgPermissionContext/types";
-import { getObjectFromSeconds, SECONDS_PER_DAY } from "@app/helpers/datetime";
+import { getObjectFromSeconds } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -54,6 +54,7 @@ import { UsePopUpState } from "@app/hooks/usePopUp";
import { LockoutTab } from "./lockout/LockoutTab";
import { superRefineLockout } from "./lockout/super-refine";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -149,7 +150,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
});
}
}
- });
+ })
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -401,7 +403,6 @@ export const IdentityLdapAuthForm = ({
const templateTooltipText =
scope === "template" ? "This field cannot be modified when using a template" : null;
const templateDisabledClass = scope === "template" ? "opacity-55" : "";
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
return (
<form
@@ -472,7 +473,7 @@ export const IdentityLdapAuthForm = ({
<SelectTrigger id="ldap-scope" className="w-full" isError={Boolean(error)}>
<SelectValue placeholder="Select configuration type" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value="template">Use Template</SelectItem>
<SelectItem value="custom">Custom Configuration</SelectItem>
</SelectContent>
@@ -506,7 +507,7 @@ export const IdentityLdapAuthForm = ({
<SelectTrigger id="ldap-template" className="w-full" isError={Boolean(error)}>
<SelectValue placeholder="Select a template" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
{templates?.map((template) => {
return (
<SelectItem value={template.id} key={template.id}>
@@ -534,7 +535,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>{templateTooltipText}</TooltipContent>
+ <TooltipContent className="max-w-md">{templateTooltipText}</TooltipContent>
</Tooltip>
)}
</FieldLabel>
@@ -562,7 +563,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>{templateTooltipText}</TooltipContent>
+ <TooltipContent className="max-w-md">{templateTooltipText}</TooltipContent>
</Tooltip>
)}
</FieldLabel>
@@ -589,7 +590,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>{templateTooltipText}</TooltipContent>
+ <TooltipContent className="max-w-md">{templateTooltipText}</TooltipContent>
</Tooltip>
)}
</FieldLabel>
@@ -617,7 +618,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>{templateTooltipText}</TooltipContent>
+ <TooltipContent className="max-w-md">{templateTooltipText}</TooltipContent>
</Tooltip>
)}
</FieldLabel>
@@ -668,7 +669,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent className="max-w-[420px]">
+ <TooltipContent className="max-w-md">
<div className="max-h-[300px] space-y-4 overflow-y-auto text-sm">
<p>
Specify the fields that the user must contain in their LDAP
@@ -759,71 +760,7 @@ export const IdentityLdapAuthForm = ({
</Button>
</div>
- <Controller
- control={control}
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL" className="inline-flex items-center gap-1.5">
- Access Token TTL (seconds)
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent>
- The lifetime for an acccess token in seconds. This value will be referenced
- at renewal time.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel
- htmlFor="accessTokenMaxTTL"
- className="inline-flex items-center gap-1.5"
- >
- Access Token Max TTL (seconds)
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent>
- The maximum lifetime for an access token in seconds. This value will be
- referenced at renewal time.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
name="accessTokenNumUsesLimit"
@@ -838,7 +775,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
@@ -884,7 +821,7 @@ export const IdentityLdapAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
{templateTooltipText ||
"An optional PEM-encoded CA cert for the LDAP server. This is used by the TLS client for secure communication with the LDAP server."}
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx
index 8443b4f4b1..908cb02a94 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOciAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -22,11 +21,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -37,6 +36,7 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -57,7 +57,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenNumUsesLimit: z.string(),
accessTokenTrustedIps: trustedIpsSchema
})
- .required();
+ .required()
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -189,8 +190,6 @@ export const IdentityOciAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -241,50 +240,7 @@ export const IdentityOciAuthForm = ({
</Field>
)}
/>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -300,7 +256,7 @@ export const IdentityOciAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
index e051918d2f..26ac1cd0dd 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityOidcAuthForm.tsx
@@ -10,7 +10,6 @@ import { BashGlobPatternTooltip } from "@app/components/permissions";
import {
Button,
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -26,11 +25,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -38,44 +37,47 @@ import { useAddIdentityOidcAuth, useUpdateIdentityOidcAuth } from "@app/hooks/ap
import { useGetIdentityOidcAuth } from "@app/hooks/api/identities/queries";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
const buildSchema = (maxAccessTokenTTL: number) =>
- z.object({
- accessTokenTrustedIps: trustedIpsSchema,
- accessTokenTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token TTL"),
- accessTokenMaxTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token Max TTL"),
- accessTokenNumUsesLimit: z.string(),
- oidcDiscoveryUrl: z
- .string()
- .url()
- .min(1)
- .refine(
- (el) => !el.endsWith("/.well-known/openid-configuration"),
- "Please remove /.well-known/openid-configuration."
- ),
- caCert: z.string().trim().default(""),
- boundIssuer: z.string().min(1),
- boundAudiences: z.string().optional().default(""),
- boundClaims: z
- .array(
- z.object({
- key: z.string(),
- value: z.string()
- })
- )
- .default([]),
- claimMetadataMapping: z
- .array(
- z.object({
- key: z.string(),
- value: z.string()
- })
- )
- .default([]),
- boundSubject: z.string().optional().default("")
- });
+ z
+ .object({
+ accessTokenTrustedIps: trustedIpsSchema,
+ accessTokenTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token TTL"),
+ accessTokenMaxTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token Max TTL"),
+ accessTokenNumUsesLimit: z.string(),
+ oidcDiscoveryUrl: z
+ .string()
+ .url()
+ .min(1)
+ .refine(
+ (el) => !el.endsWith("/.well-known/openid-configuration"),
+ "Please remove /.well-known/openid-configuration."
+ ),
+ caCert: z.string().trim().default(""),
+ boundIssuer: z.string().min(1),
+ boundAudiences: z.string().optional().default(""),
+ boundClaims: z
+ .array(
+ z.object({
+ key: z.string(),
+ value: z.string()
+ })
+ )
+ .default([]),
+ claimMetadataMapping: z
+ .array(
+ z.object({
+ key: z.string(),
+ value: z.string()
+ })
+ )
+ .default([]),
+ boundSubject: z.string().optional().default("")
+ })
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -263,8 +265,6 @@ export const IdentityOidcAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -330,7 +330,7 @@ export const IdentityOidcAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<BashGlobPatternTooltip />
</TooltipContent>
</Tooltip>
@@ -351,7 +351,7 @@ export const IdentityOidcAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<BashGlobPatternTooltip />
</TooltipContent>
</Tooltip>
@@ -385,7 +385,7 @@ export const IdentityOidcAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
<BashGlobPatternTooltip />
</TooltipContent>
</Tooltip>
@@ -452,50 +452,7 @@ export const IdentityOidcAuthForm = ({
</Button>
</div>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -511,7 +468,7 @@ export const IdentityOidcAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
@@ -569,7 +526,7 @@ export const IdentityOidcAuthForm = ({
<TooltipTrigger asChild>
<HelpCircleIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent className="text-center">
+ <TooltipContent className="max-w-md text-center">
<div className="w-[180px]">
<p>Map OIDC token claims to metadata fields</p>
<p className="mt-2 text-sm">Example:</p>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySpiffeAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySpiffeAuthForm.tsx
index c97ee56420..499d4df1ac 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySpiffeAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentitySpiffeAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -28,11 +27,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -41,6 +40,7 @@ import { SpiffeTrustBundleProfile } from "@app/hooks/api/identities/enums";
import { useGetIdentitySpiffeAuth } from "@app/hooks/api/identities/queries";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -67,7 +67,9 @@ const buildSchema = (maxAccessTokenTTL: number) => {
accessTokenMaxTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token Max TTL"),
accessTokenNumUsesLimit: z.string()
});
- return common.extend({ trustBundleDistribution: trustBundleDistributionSchema });
+ return common
+ .extend({ trustBundleDistribution: trustBundleDistributionSchema })
+ .superRefine(superRefineAccessTokenTtl);
};
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -254,8 +256,6 @@ export const IdentitySpiffeAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -288,7 +288,7 @@ export const IdentitySpiffeAuthForm = ({
>
<SelectValue placeholder="Select trust bundle profile" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value={SpiffeTrustBundleProfile.STATIC}>Static</SelectItem>
<SelectItem value={SpiffeTrustBundleProfile.HTTPS_WEB_BUNDLE}>
HTTPS Web Bundle
@@ -427,50 +427,7 @@ export const IdentitySpiffeAuthForm = ({
/>
</>
)}
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -486,7 +443,7 @@ export const IdentitySpiffeAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx
index 311a299443..efd8dbf8ad 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTlsCertAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -23,11 +22,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -38,18 +37,21 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
const buildSchema = (maxAccessTokenTTL: number) =>
- z.object({
- allowedCommonNames: z.string().optional(),
- caCertificate: z.string().min(1),
- accessTokenTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token TTL"),
- accessTokenMaxTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token Max TTL"),
- accessTokenNumUsesLimit: z.string(),
- accessTokenTrustedIps: trustedIpsSchema
- });
+ z
+ .object({
+ allowedCommonNames: z.string().optional(),
+ caCertificate: z.string().min(1),
+ accessTokenTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token TTL"),
+ accessTokenMaxTTL: accessTokenTtlSchema(maxAccessTokenTTL, "Access Token Max TTL"),
+ accessTokenNumUsesLimit: z.string(),
+ accessTokenTrustedIps: trustedIpsSchema
+ })
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -179,8 +181,6 @@ export const IdentityTlsCertAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form id={IDENTITY_AUTH_FORM_ID} onSubmit={handleSubmit(onFormSubmit)}>
<Tabs value={tabValue} onValueChange={(value) => setTabValue(value as IdentityFormTab)}>
@@ -201,7 +201,7 @@ export const IdentityTlsCertAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
A PEM-encoded CA certificate. This will be used to validate client
certificate.
</TooltipContent>
@@ -233,7 +233,7 @@ export const IdentityTlsCertAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
Comma separated common names allowed to authenticate against the identity.
Leave empty to allow any certificate.
</TooltipContent>
@@ -244,73 +244,7 @@ export const IdentityTlsCertAuthForm = ({
</Field>
)}
/>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL" className="inline-flex items-center gap-1.5">
- Access Token TTL (seconds)
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent>
- The lifetime for an access token in seconds. This value will be referenced
- at renewal time.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel
- htmlFor="accessTokenMaxTTL"
- className="inline-flex items-center gap-1.5"
- >
- Access Token Max TTL (seconds)
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent>
- The maximum lifetime for an access token in seconds. This value will be
- referenced at renewal time.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -326,7 +260,7 @@ export const IdentityTlsCertAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx
index edbb4b71dd..2708f457d1 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityTokenAuthForm.tsx
@@ -8,7 +8,6 @@ import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Field,
- FieldDescription,
FieldError,
FieldGroup,
FieldLabel,
@@ -22,11 +21,11 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { SECONDS_PER_DAY } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -37,6 +36,7 @@ import {
} from "@app/hooks/api";
import { UsePopUpState } from "@app/hooks/usePopUp";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -48,7 +48,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
accessTokenNumUsesLimit: z.string(),
accessTokenTrustedIps: trustedIpsSchema
})
- .required();
+ .required()
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -169,8 +170,6 @@ export const IdentityTokenAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -189,50 +188,7 @@ export const IdentityTokenAuthForm = ({
</TabsList>
<TabsContent value={IdentityFormTab.Configuration}>
<FieldGroup>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
<Controller
control={control}
defaultValue="0"
@@ -248,7 +204,7 @@ export const IdentityTokenAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
index ae8198a222..7afba62a62 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/IdentityUniversalAuthForm.tsx
@@ -23,11 +23,12 @@ import {
TooltipTrigger
} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
-import { getObjectFromSeconds, SECONDS_PER_DAY } from "@app/helpers/datetime";
+import { getObjectFromSeconds } from "@app/helpers/datetime";
import {
accessTokenTtlSchema,
DEFAULT_TRUSTED_IPS,
mapTrustedIpsFromServer,
+ superRefineAccessTokenTtl,
trustedIpsSchema
} from "@app/helpers/identityAuthSchemas";
import { useScopeVariant } from "@app/hooks";
@@ -40,6 +41,7 @@ import { UsePopUpState } from "@app/hooks/usePopUp";
import { LockoutTab } from "./lockout/LockoutTab";
import { superRefineLockout } from "./lockout/super-refine";
+import { AccessTokenTtlFields } from "./shared/AccessTokenTtlFields";
import { TrustedIpsField } from "./shared/TrustedIpsField";
import { IDENTITY_AUTH_FORM_ID, IdentityFormTab } from "./types";
@@ -69,7 +71,8 @@ const buildSchema = (maxAccessTokenTTL: number) =>
})
})
.required()
- .superRefine(superRefineLockout);
+ .superRefine(superRefineLockout)
+ .superRefine(superRefineAccessTokenTtl);
export type FormData = z.infer<ReturnType<typeof buildSchema>>;
@@ -253,8 +256,6 @@ export const IdentityUniversalAuthForm = ({
reset();
};
- const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
-
return (
<form
id={IDENTITY_AUTH_FORM_ID}
@@ -293,52 +294,7 @@ export const IdentityUniversalAuthForm = ({
When Access Token Period is set, TTL and Max TTL are ignored.
</div>
) : (
- <>
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenTTL">Access Token TTL (seconds)</FieldLabel>
- <Input
- {...field}
- id="accessTokenTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- <Controller
- control={control}
- defaultValue="2592000"
- name="accessTokenMaxTTL"
- render={({ field, fieldState: { error } }) => (
- <Field>
- <FieldLabel htmlFor="accessTokenMaxTTL">
- Access Token Max TTL (seconds)
- </FieldLabel>
- <Input
- {...field}
- id="accessTokenMaxTTL"
- placeholder="2592000"
- type="number"
- min="1"
- step="1"
- isError={Boolean(error)}
- />
- <FieldDescription>{maxDaysHelper}</FieldDescription>
- <FieldError>{error?.message}</FieldError>
- </Field>
- )}
- />
- </>
+ <AccessTokenTtlFields control={control} maxAccessTokenTTL={maxAccessTokenTTL} />
)}
<Controller
control={control}
@@ -355,7 +311,7 @@ export const IdentityUniversalAuthForm = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The maximum number of times that an access token can be used; leave blank
for unlimited uses.
</TooltipContent>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/lockout/LockoutTab.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/lockout/LockoutTab.tsx
index 1c751b1142..5e836e339b 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/lockout/LockoutTab.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/lockout/LockoutTab.tsx
@@ -82,7 +82,7 @@ export const LockoutTab = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
The amount of times login must fail before locking the identity auth method
</TooltipContent>
</Tooltip>
@@ -116,7 +116,7 @@ export const LockoutTab = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
How long an identity auth method lockout lasts
</TooltipContent>
</Tooltip>
@@ -150,7 +150,7 @@ export const LockoutTab = ({
<SelectTrigger id="lockoutDurationUnit" isError={Boolean(error)}>
<SelectValue placeholder="Select unit" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value="s">Seconds</SelectItem>
<SelectItem value="m">Minutes</SelectItem>
<SelectItem value="h">Hours</SelectItem>
@@ -178,7 +178,7 @@ export const LockoutTab = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>
+ <TooltipContent className="max-w-md">
How long to wait from the most recent failed login until resetting the
lockout counter
</TooltipContent>
@@ -217,7 +217,7 @@ export const LockoutTab = ({
>
<SelectValue placeholder="Select unit" />
</SelectTrigger>
- <SelectContent>
+ <SelectContent position="popper">
<SelectItem value="s">Seconds</SelectItem>
<SelectItem value="m">Minutes</SelectItem>
<SelectItem value="h">Hours</SelectItem>
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/AccessTokenTtlFields.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/AccessTokenTtlFields.tsx
new file mode 100644
index 0000000000..1bb49c312f
--- /dev/null
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/AccessTokenTtlFields.tsx
@@ -0,0 +1,96 @@
+import { Control, Controller } from "react-hook-form";
+import { InfoIcon } from "lucide-react";
+
+import {
+ Field,
+ FieldDescription,
+ FieldError,
+ FieldLabel,
+ Input,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
+} from "@app/components/v3";
+import { SECONDS_PER_DAY } from "@app/helpers/datetime";
+
+type Props = {
+ control: Control<any>;
+ /** Server-enforced upper bound (seconds) used to render the "Max: N days" helper. */
+ maxAccessTokenTTL: number;
+};
+
+/**
+ * Shared editor for an identity auth method's `accessTokenTTL` and `accessTokenMaxTTL`
+ * fields, which every auth method exposes identically. Pair this with
+ * `superRefineAccessTokenTtl` in the form schema to enforce TTL <= Max TTL.
+ */
+export const AccessTokenTtlFields = ({ control, maxAccessTokenTTL }: Props) => {
+ const maxDaysHelper = `Max: ${Math.floor(maxAccessTokenTTL / SECONDS_PER_DAY)} days`;
+
+ return (
+ <>
+ <Controller
+ control={control}
+ name="accessTokenTTL"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="accessTokenTTL" className="inline-flex items-center gap-1.5">
+ Access Token TTL (seconds)
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-md">
+ The lifetime for an access token in seconds. This value will be referenced at
+ renewal time.
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="accessTokenTTL"
+ placeholder="2592000"
+ type="number"
+ min="1"
+ step="1"
+ isError={Boolean(error)}
+ />
+ <FieldDescription>{maxDaysHelper}</FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ <Controller
+ control={control}
+ name="accessTokenMaxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel htmlFor="accessTokenMaxTTL" className="inline-flex items-center gap-1.5">
+ Access Token Max TTL (seconds)
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <InfoIcon className="size-3.5 text-muted" />
+ </TooltipTrigger>
+ <TooltipContent className="max-w-md">
+ The maximum lifetime for an access token in seconds. This value will be referenced
+ at renewal time.
+ </TooltipContent>
+ </Tooltip>
+ </FieldLabel>
+ <Input
+ {...field}
+ id="accessTokenMaxTTL"
+ placeholder="2592000"
+ type="number"
+ min="1"
+ step="1"
+ isError={Boolean(error)}
+ />
+ <FieldDescription>{maxDaysHelper}</FieldDescription>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
+ )}
+ />
+ </>
+ );
+};
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/TrustedIpsField.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/TrustedIpsField.tsx
index 223e97ae72..eb6ebc3eca 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/TrustedIpsField.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgIdentityTab/components/IdentitySection/shared/TrustedIpsField.tsx
@@ -76,7 +76,7 @@ export const TrustedIpsField = ({
<TooltipTrigger asChild>
<InfoIcon className="size-3.5 text-muted" />
</TooltipTrigger>
- <TooltipContent>{tooltip}</TooltipContent>
+ <TooltipContent className="max-w-md">{tooltip}</TooltipContent>
</Tooltip>
)}
</FieldLabel>
@@ -108,7 +108,7 @@ export const TrustedIpsField = ({
</IconButton>
</span>
</TooltipTrigger>
- {isLast && <TooltipContent>At least one IP is required</TooltipContent>}
+ {isLast && <TooltipContent className="max-w-md">At least one IP is required</TooltipContent>}
</Tooltip>
</div>
))}