mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 22:27:48 +00:00
Type check fixes
This commit is contained in:
+5
-1
@@ -148,7 +148,11 @@ export const IdentityModal = ({ popUp, handlePopUpToggle }: Props) => {
|
|||||||
accessTokenTTL: 2592000,
|
accessTokenTTL: 2592000,
|
||||||
accessTokenMaxTTL: 2592000,
|
accessTokenMaxTTL: 2592000,
|
||||||
accessTokenNumUsesLimit: 0,
|
accessTokenNumUsesLimit: 0,
|
||||||
accessTokenPeriod: 0
|
accessTokenPeriod: 0,
|
||||||
|
lockoutEnabled: true,
|
||||||
|
lockoutThreshold: 3,
|
||||||
|
lockoutDuration: 300,
|
||||||
|
lockoutCounterReset: 30
|
||||||
});
|
});
|
||||||
|
|
||||||
handlePopUpToggle("identity", false);
|
handlePopUpToggle("identity", false);
|
||||||
|
|||||||
+40
-35
@@ -20,6 +20,7 @@ import {
|
|||||||
Tabs
|
Tabs
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { useOrganization, useSubscription } from "@app/context";
|
import { useOrganization, useSubscription } from "@app/context";
|
||||||
|
import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime";
|
||||||
import {
|
import {
|
||||||
useAddIdentityUniversalAuth,
|
useAddIdentityUniversalAuth,
|
||||||
useGetIdentityUniversalAuth,
|
useGetIdentityUniversalAuth,
|
||||||
@@ -29,7 +30,6 @@ import { IdentityTrustedIp } from "@app/hooks/api/identities/types";
|
|||||||
import { UsePopUpState } from "@app/hooks/usePopUp";
|
import { UsePopUpState } from "@app/hooks/usePopUp";
|
||||||
|
|
||||||
import { IdentityFormTab } from "./types";
|
import { IdentityFormTab } from "./types";
|
||||||
import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime";
|
|
||||||
|
|
||||||
const schema = z
|
const schema = z
|
||||||
.object({
|
.object({
|
||||||
@@ -96,7 +96,7 @@ const schema = z
|
|||||||
let isAnyParseError = false;
|
let isAnyParseError = false;
|
||||||
|
|
||||||
const parsedLockoutDuration = parseInt(lockoutDurationValue, 10);
|
const parsedLockoutDuration = parseInt(lockoutDurationValue, 10);
|
||||||
if (isNaN(parsedLockoutDuration)) {
|
if (Number.isNaN(parsedLockoutDuration)) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: "Lockout duration must be a number",
|
message: "Lockout duration must be a number",
|
||||||
@@ -106,7 +106,7 @@ const schema = z
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parsedLockoutCounterReset = parseInt(lockoutCounterResetValue, 10);
|
const parsedLockoutCounterReset = parseInt(lockoutCounterResetValue, 10);
|
||||||
if (isNaN(parsedLockoutCounterReset)) {
|
if (Number.isNaN(parsedLockoutCounterReset)) {
|
||||||
ctx.addIssue({
|
ctx.addIssue({
|
||||||
code: z.ZodIssueCode.custom,
|
code: z.ZodIssueCode.custom,
|
||||||
message: "Lockout counter reset must be a number",
|
message: "Lockout counter reset must be a number",
|
||||||
@@ -195,12 +195,12 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
|
|
||||||
const accessTokenPeriodValue = Number(watch("accessTokenPeriod"));
|
const accessTokenPeriodValue = Number(watch("accessTokenPeriod"));
|
||||||
|
|
||||||
const lockoutEnabled = watch("lockoutEnabled");
|
const lockoutEnabledWatch = watch("lockoutEnabled");
|
||||||
const lockoutThreshold = watch("lockoutThreshold");
|
const lockoutThresholdWatch = watch("lockoutThreshold");
|
||||||
const lockoutDurationValue = watch("lockoutDurationValue");
|
const lockoutDurationValueWatch = watch("lockoutDurationValue");
|
||||||
const lockoutDurationUnit = watch("lockoutDurationUnit");
|
const lockoutDurationUnitWatch = watch("lockoutDurationUnit");
|
||||||
const lockoutCounterResetValue = watch("lockoutCounterResetValue");
|
const lockoutCounterResetValueWatch = watch("lockoutCounterResetValue");
|
||||||
const lockoutCounterResetUnit = watch("lockoutCounterResetUnit");
|
const lockoutCounterResetUnitWatch = watch("lockoutCounterResetUnit");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
fields: clientSecretTrustedIpsFields,
|
fields: clientSecretTrustedIpsFields,
|
||||||
@@ -341,20 +341,25 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
return (
|
return (
|
||||||
<form
|
<form
|
||||||
onSubmit={handleSubmit(onFormSubmit, (fields) => {
|
onSubmit={handleSubmit(onFormSubmit, (fields) => {
|
||||||
setTabValue(
|
const firstErrorField = Object.keys(fields)[0];
|
||||||
["accessTokenTrustedIps", "clientSecretTrustedIps"].includes(Object.keys(fields)[0])
|
let tab = IdentityFormTab.Configuration;
|
||||||
? IdentityFormTab.Advanced
|
|
||||||
: [
|
if (["accessTokenTrustedIps", "clientSecretTrustedIps"].includes(firstErrorField)) {
|
||||||
"lockoutEnabled",
|
tab = IdentityFormTab.Advanced;
|
||||||
"lockoutThreshold",
|
} else if (
|
||||||
"lockoutDurationValue",
|
[
|
||||||
"lockoutDurationUnit",
|
"lockoutEnabled",
|
||||||
"lockoutCounterResetValue",
|
"lockoutThreshold",
|
||||||
"lockoutCounterResetUnit"
|
"lockoutDurationValue",
|
||||||
].includes(Object.keys(fields)[0])
|
"lockoutDurationUnit",
|
||||||
? IdentityFormTab.Lockout
|
"lockoutCounterResetValue",
|
||||||
: IdentityFormTab.Configuration
|
"lockoutCounterResetUnit"
|
||||||
);
|
].includes(firstErrorField)
|
||||||
|
) {
|
||||||
|
tab = IdentityFormTab.Lockout;
|
||||||
|
}
|
||||||
|
|
||||||
|
setTabValue(tab);
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Tabs value={tabValue} onValueChange={(value) => setTabValue(value as IdentityFormTab)}>
|
<Tabs value={tabValue} onValueChange={(value) => setTabValue(value as IdentityFormTab)}>
|
||||||
@@ -435,11 +440,11 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="lockoutEnabled"
|
name="lockoutEnabled"
|
||||||
defaultValue={true}
|
defaultValue
|
||||||
render={({ field: { value, onChange }, fieldState: { error } }) => {
|
render={({ field: { value, onChange }, fieldState: { error } }) => {
|
||||||
return (
|
return (
|
||||||
<FormControl
|
<FormControl
|
||||||
helperText={`The lockout feature will prevent login attempts for ${lockoutDurationValue}${lockoutDurationUnit} after ${lockoutThreshold} consecutive login failures. If ${lockoutCounterResetValue}${lockoutCounterResetUnit} pass after the most recent failure, the lockout counter resets.`}
|
helperText={`The lockout feature will prevent login attempts for ${lockoutDurationValueWatch}${lockoutDurationUnitWatch} after ${lockoutThresholdWatch} consecutive login failures. If ${lockoutCounterResetValueWatch}${lockoutCounterResetUnitWatch} pass after the most recent failure, the lockout counter resets.`}
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
>
|
>
|
||||||
@@ -464,7 +469,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
render={({ field, fieldState: { error } }) => {
|
render={({ field, fieldState: { error } }) => {
|
||||||
return (
|
return (
|
||||||
<FormControl
|
<FormControl
|
||||||
className={`mb-0 flex-grow ${lockoutEnabled ? "" : "opacity-70"}`}
|
className={`mb-0 flex-grow ${lockoutEnabledWatch ? "" : "opacity-70"}`}
|
||||||
label="Lockout Threshold"
|
label="Lockout Threshold"
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
@@ -473,7 +478,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
placeholder="Enter lockout threshold..."
|
placeholder="Enter lockout threshold..."
|
||||||
isDisabled={!lockoutEnabled}
|
isDisabled={!lockoutEnabledWatch}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
@@ -486,7 +491,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
render={({ field, fieldState: { error } }) => {
|
render={({ field, fieldState: { error } }) => {
|
||||||
return (
|
return (
|
||||||
<FormControl
|
<FormControl
|
||||||
className={`mb-0 flex-grow ${lockoutEnabled ? "" : "opacity-70"}`}
|
className={`mb-0 flex-grow ${lockoutEnabledWatch ? "" : "opacity-70"}`}
|
||||||
label="Lockout Duration"
|
label="Lockout Duration"
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
@@ -495,7 +500,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
placeholder="Enter lockout duration..."
|
placeholder="Enter lockout duration..."
|
||||||
isDisabled={!lockoutEnabled}
|
isDisabled={!lockoutEnabledWatch}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
@@ -506,12 +511,12 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
name="lockoutDurationUnit"
|
name="lockoutDurationUnit"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
className={`mb-0 ${lockoutEnabled ? "" : "opacity-70"}`}
|
className={`mb-0 ${lockoutEnabledWatch ? "" : "opacity-70"}`}
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
isDisabled={!lockoutEnabled}
|
isDisabled={!lockoutEnabledWatch}
|
||||||
value={field.value}
|
value={field.value}
|
||||||
className="min-w-32 pr-2"
|
className="min-w-32 pr-2"
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
@@ -553,7 +558,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
render={({ field, fieldState: { error } }) => {
|
render={({ field, fieldState: { error } }) => {
|
||||||
return (
|
return (
|
||||||
<FormControl
|
<FormControl
|
||||||
className={`mb-0 flex-grow ${lockoutEnabled ? "" : "opacity-70"}`}
|
className={`mb-0 flex-grow ${lockoutEnabledWatch ? "" : "opacity-70"}`}
|
||||||
label="Lockout Counter Reset"
|
label="Lockout Counter Reset"
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
@@ -562,7 +567,7 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
<Input
|
<Input
|
||||||
{...field}
|
{...field}
|
||||||
placeholder="Enter lockout counter reset..."
|
placeholder="Enter lockout counter reset..."
|
||||||
isDisabled={!lockoutEnabled}
|
isDisabled={!lockoutEnabledWatch}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
);
|
);
|
||||||
@@ -573,12 +578,12 @@ export const IdentityUniversalAuthForm = ({
|
|||||||
name="lockoutCounterResetUnit"
|
name="lockoutCounterResetUnit"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
className={`mb-0 ${lockoutEnabled ? "" : "opacity-70"}`}
|
className={`mb-0 ${lockoutEnabledWatch ? "" : "opacity-70"}`}
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
isDisabled={!lockoutEnabled}
|
isDisabled={!lockoutEnabledWatch}
|
||||||
value={field.value}
|
value={field.value}
|
||||||
className="min-w-32 pr-2"
|
className="min-w-32 pr-2"
|
||||||
onValueChange={field.onChange}
|
onValueChange={field.onChange}
|
||||||
|
|||||||
+6
-6
@@ -1,7 +1,11 @@
|
|||||||
import { faArrowsRotate, faBan, faCheck, faCopy, faFire } from "@fortawesome/free-solid-svg-icons";
|
import { useState } from "react";
|
||||||
|
import { faBan, faCheck, faCopy } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
|
|
||||||
|
import { createNotification } from "@app/components/notifications";
|
||||||
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import { Button, EmptyState, IconButton, Spinner, Tooltip } from "@app/components/v2";
|
import { Button, EmptyState, IconButton, Spinner, Tooltip } from "@app/components/v2";
|
||||||
|
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/context";
|
||||||
import { useTimedReset } from "@app/hooks";
|
import { useTimedReset } from "@app/hooks";
|
||||||
import {
|
import {
|
||||||
useClearIdentityUniversalAuthLockouts,
|
useClearIdentityUniversalAuthLockouts,
|
||||||
@@ -14,10 +18,6 @@ import { IdentityAuthFieldDisplay } from "./IdentityAuthFieldDisplay";
|
|||||||
import { IdentityUniversalAuthClientSecretsTable } from "./IdentityUniversalAuthClientSecretsTable";
|
import { IdentityUniversalAuthClientSecretsTable } from "./IdentityUniversalAuthClientSecretsTable";
|
||||||
import { ViewAuthMethodProps } from "./types";
|
import { ViewAuthMethodProps } from "./types";
|
||||||
import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper";
|
import { ViewIdentityContentWrapper } from "./ViewIdentityContentWrapper";
|
||||||
import { OrgPermissionIdentityActions, OrgPermissionSubjects } from "@app/context";
|
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
export const ViewIdentityUniversalAuthContent = ({
|
export const ViewIdentityUniversalAuthContent = ({
|
||||||
identityId,
|
identityId,
|
||||||
@@ -119,7 +119,7 @@ export const ViewIdentityUniversalAuthContent = ({
|
|||||||
<Button
|
<Button
|
||||||
isDisabled={!isAllowed || !lockedOutState || isClearLockoutsPending}
|
isDisabled={!isAllowed || !lockedOutState || isClearLockoutsPending}
|
||||||
size="xs"
|
size="xs"
|
||||||
onClick={clearLockouts}
|
onClick={() => clearLockouts()}
|
||||||
isLoading={isClearLockoutsPending}
|
isLoading={isClearLockoutsPending}
|
||||||
colorSchema="secondary"
|
colorSchema="secondary"
|
||||||
>
|
>
|
||||||
|
|||||||
+1
-1
@@ -7,8 +7,8 @@ import { createNotification } from "@app/components/notifications";
|
|||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";
|
import { Button, FormControl, Input, Select, SelectItem } from "@app/components/v2";
|
||||||
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
|
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
|
||||||
import { useUpdateOrg } from "@app/hooks/api";
|
|
||||||
import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime";
|
import { durationToSeconds, getObjectFromSeconds } from "@app/helpers/datetime";
|
||||||
|
import { useUpdateOrg } from "@app/hooks/api";
|
||||||
|
|
||||||
const MAX_SHARED_SECRET_LIFETIME_SECONDS = 30 * 24 * 60 * 60; // 30 days in seconds
|
const MAX_SHARED_SECRET_LIFETIME_SECONDS = 30 * 24 * 60 * 60; // 30 days in seconds
|
||||||
const MIN_SHARED_SECRET_LIFETIME_SECONDS = 5 * 60; // 5 minutes in seconds
|
const MIN_SHARED_SECRET_LIFETIME_SECONDS = 5 * 60; // 5 minutes in seconds
|
||||||
|
|||||||
Reference in New Issue
Block a user