Skip to content

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

Merge branch 'feat/adilsitos/eng-4966-stack-1' into feat/adilsitos/eng-4966-stack-2

adilsonef9f149a4cc7
diff --cc CLAUDE.md
index 1cf042ada7,35f6f0eb92..4f7b46bc22
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@@ -148,45 -148,15 +148,54 @@@ for product vocabulary only: resolving
Any rule about what is *allowed* belongs in the resource, or the product's own API and the shared API
stop agreeing.
+A policy on the global approval system can hand its requests to a delegated approval system (ServiceNow)
+through `backend/src/services/delegated-approval/`, which owns the `delegated_approval_policies` and
+`delegated_approval_requests` rows. Secret access policies opt in with `delegatedApproval: { type, connectionId }`
+on create and update (`secret-access-approval-global-policy-bridge-service.ts`). A delegated policy has no
+Infisical approvers, cannot use break glass (soft enforcement or bypassers) or self approval, cannot be updated
+while it has pending requests, and a policy on the legacy approval system can never be delegated. Keep those
+rules in `assertDelegatedApprovalPolicyConstraints` when another policy type opts in. Only secret access
+policies may opt in today: `assertPolicyTypeSupportsDelegatedApproval` refuses the rest, and secret change
+policies return it as a 400 rather than dropping the field.
+
+Delivery to the delegated system is asynchronous and goes through the event outbox (see `backend/CLAUDE.md`).
+`delegatedApprovalService.createRequest` writes the `delegated_approval_requests` row and emits
+`delegated-approval.request.dispatch-requested` (`delegated-approval-events.ts`) in the caller's transaction, so
+the dispatch is exactly as durable as the request; never enqueue it after commit. The
+`delegated-approval-dispatch` consumer (`delegated-approval/dispatch/delegated-approval-dispatch-consumer.ts`)
+calls the provider inline and moves the row `pending_dispatch` → `waiting_approval` (storing the provider's
+record id in `providerRequestId`) or `failed_dispatch` with a `statusReason` a user can read. A transient
+failure returns `Retry`, so the outbox backs off and tries again (up to `MAX_OUTBOX_ATTEMPTS`); the reason text
+promises that retry on every attempt because the consumer cannot see the attempt count. A user resends a
+`failed_dispatch` request with `POST /api/v1/access-approvals/requests/:requestId/retry-delegated-dispatch`. The
+product's bridge checks who may retry, and `delegatedApprovalService.retryDispatch` checks the request can be
+retried and emits the same event with no transaction. One flush runs per consumer at a time, so two dispatches
+of one request never run together; a second event for a request that was already delivered is marked delivered
+without calling the provider. A delegated request has
+no Infisical approvers, so `POST /api/v1/access-approvals/requests/:requestId/cancel-delegated-dispatch` is the only way to close
+one from Infisical: the requester, or anyone who can edit the policy, sets it `cancelled`, which is also how a
+policy blocked by pending requests is freed for editing. Every provider implements `TDelegatedApprovalProvider` against the same
+`TDelegatedApprovalDispatchInput` and registers in `DELEGATED_APPROVAL_PROVIDER_MAP`
+(`dispatch/providers/<name>/`); a new policy type adds an arm to `TDelegatedApprovalDispatchDetails` and a
+builder in `DELEGATED_APPROVAL_DISPATCH_DETAILS_BUILDER_MAP` rather than branching in a provider. The consumer
+reads from the primary, never checks the license, and treats bullmq's `UnrecoverableError` as the terminal failure
+signal, returning `Failed` for it and `Retry` for anything else. The callback contract (token issuance now, the inbound route and approve / reject later) is its own
+module, `backend/src/services/delegated-approval-callback/`, so the delegated approval module never grows a
+callback branch. A request gets exactly one callback token for its whole life: it is random, issued on the first
+dispatch attempt, and stored encrypted under the org KMS key in `encryptedCallbackToken` so every retry resends
+the same value; the inbound side finds the row by the provider's record id and compares the decrypted token with
+the presented one. Never send a provider a token that differs from the one stored for the request; the provider
+keeps the first token it was given and cannot be told another, so a mismatch is unrecoverable.
+
+ ### Object Storage
+
+ New product files go to S3 through `backend/src/services/object-storage/`, not a product's own S3 client (PAM
+ recordings predate it and haven't moved). A product
+ registers a namespace (record-first path like `sessions/{sessionId}/logs/{file}`, checked for naming collisions at
+ boot) and the layer builds org-first keys, signs links, and applies the retention tag and, for default storage on Infisical Cloud, a daily upload cap. Storage is
+ `default` (the instance's bucket, `OBJECT_STORAGE_S3_*`) or `external` (the customer's, through an AWS connection);
+ use those two words everywhere.
+
### API Layer (Frontend)
React Query + Axios with query key factories per domain. Each API domain in `frontend/src/hooks/api/` has `queries.tsx`, `mutations.tsx`, and `types.tsx` — see `frontend/CLAUDE.md` for conventions.
diff --cc backend/src/server/routes/index.ts
index b1b0730fec,1582f3cf54..963831af0e
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@@ -3239,119 -3318,16 +3241,129 @@@ export const registerRoutes = async
keyStore
});
+ const delegatedApprovalCallbackService = delegatedApprovalCallbackServiceFactory({
+ delegatedApprovalRequestDAL,
+ kmsService
+ });
+
+ eventOutboxRegistry.register(
+ delegatedApprovalDispatchConsumerFactory({
+ delegatedApprovalRequestDAL,
+ delegatedApprovalPolicyDAL,
+ delegatedApprovalCallbackService,
+ approvalRequestDAL,
+ projectDAL,
+ appConnectionDAL,
+ kmsService
+ })
+ );
+
+ const delegatedApprovalService = delegatedApprovalServiceFactory({
+ delegatedApprovalPolicyDAL,
+ delegatedApprovalRequestDAL,
+ approvalPolicyDAL,
+ appConnectionDAL,
+ appConnectionService,
+ eventEmitter: eventOutboxService
+ });
+
+ const secretAccessApprovalGlobalRequestBridgeService = secretAccessApprovalGlobalRequestBridgeServiceFactory({
+ projectDAL,
+ projectEnvDAL,
+ permissionService,
+ userDAL,
+ userGroupMembershipDAL,
+ approvalRequestDAL,
+ approvalRequestStepsDAL,
+ approvalRequestStepEligibleApproversDAL,
+ approvalRequestApprovalsDAL,
+ approvalRequestGrantsDAL,
+ additionalPrivilegeDAL,
+ secretAccessApprovalGlobalPolicyBridgeDAL,
+ secretAccessApprovalGlobalRequestBridgeDAL,
+ approvalPolicyDAL,
+ delegatedApprovalService,
+ smtpService,
+ notificationService,
+ kmsService,
+ projectSlackConfigDAL,
+ microsoftTeamsService,
+ projectMicrosoftTeamsConfigDAL,
+ queueService,
+ secretAccessApprovalGlobalResource
+ });
+
+ const accessApprovalRequestService = accessApprovalRequestServiceFactory({
+ projectDAL,
+ permissionService,
+ accessApprovalRequestReviewerDAL,
+ accessApprovalPolicyDAL,
+ secretAccessApprovalGlobalResource,
+ secretAccessApprovalGlobalRequestBridge: secretAccessApprovalGlobalRequestBridgeService,
+ accessApprovalRequestDAL,
+ projectEnvDAL,
+ userDAL,
+ smtpService,
+ accessApprovalPolicyApproverDAL,
+ projectSlackConfigDAL,
+ kmsService,
+ groupDAL,
+ microsoftTeamsService,
+ projectMicrosoftTeamsConfigDAL,
+ notificationService,
+ additionalPrivilegeDAL,
+ queueService
+ });
+
+ const secretAccessApprovalGlobalPolicyBridgeService = secretAccessApprovalGlobalPolicyBridgeServiceFactory({
+ projectDAL,
+ permissionService,
+ projectEnvDAL,
+ userDAL,
+ groupDAL,
+ accessApprovalPolicyDAL,
+ approvalPolicyDAL,
+ approvalPolicyStepsDAL,
+ approvalPolicyStepApproversDAL,
+ approvalPolicyBypassersDAL,
+ approvalPolicySecretEnvironmentDAL,
+ secretAccessApprovalGlobalPolicyBridgeDAL,
+ approvalRequestDAL,
+ approvalRequestStepsDAL,
+ approvalRequestStepEligibleApproversDAL,
+ approvalRequestGrantsDAL,
+ additionalPrivilegeDAL,
+ delegatedApprovalService
+ });
+
+ const accessApprovalPolicyService = accessApprovalPolicyServiceFactory({
+ accessApprovalPolicyDAL,
+ accessApprovalPolicyApproverDAL,
+ accessApprovalPolicyBypasserDAL,
+ accessApprovalPolicyEnvironmentDAL,
+ groupDAL,
+ permissionService,
+ projectEnvDAL,
+ projectDAL,
+ userDAL,
+ accessApprovalRequestDAL,
+ accessApprovalRequestReviewerDAL,
+ additionalPrivilegeDAL,
+ approvalPolicyDAL,
+ approvalPolicySecretEnvironmentDAL,
+ secretAccessApprovalGlobalPolicyBridge: secretAccessApprovalGlobalPolicyBridgeService
+ });
+
+ const objectStorageService = objectStorageServiceFactory({ appConnectionDAL, kmsService, keyStore });
+ objectStorageService.registerNamespaces([AgentVaultSessionLogsNamespace]);
+ // Not awaited: a misconfigured instance bucket is logged, and must not hold up boot. Only pods that serve the API use
+ // default storage, so only they check it.
+ if (envConfig.isApiRunModeEnabled) {
+ void objectStorageService
+ .checkDefaultStorage()
+ .catch((error) => logger.error(error, "objectStorage: could not check default storage"));
+ }
+
const agentVaultSessionLogService = agentVaultSessionLogServiceFactory({
agentVaultSessionLogConfigDAL,
agentVaultSessionDAL,
diff --cc frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx
index 5759b6176b,8a35d2e9a8..cd6bc7c22e
--- a/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx
+++ b/frontend/src/pages/secret-manager/SecretApprovalsPage/components/ApprovalPolicyList/components/AccessPolicyModal.tsx
@@@ -944,318 -873,276 +939,318 @@@ const Form = (
)}
/>
)}
- <div>
- <p className="text-sm font-medium text-foreground">Approvers</p>
- <p className="text-xs text-muted">
- Select readable members or groups, or enter an exact project member email.
- </p>
- </div>
- {isAccessPolicyType ? (
+ {isAccessPolicyType && (
<>
- {sequenceApproversFieldArray.fields.length === 1 ? (
- <div className="flex items-start gap-3">
- <Field className="min-w-0 flex-1">
- <FieldLabel>Approvers</FieldLabel>
- <FieldContent>
- {renderApproverSelect(0)}
- <FieldError
- errors={[
- errors.sequenceApprovers?.[0]?.user,
- errors.sequenceApprovers?.[0]?.group
- ]}
- />
- </FieldContent>
- </Field>
- <Field className="w-28">
- <FieldLabel>Min. Approvals</FieldLabel>
- <FieldContent>{renderMinApprovals(0, "h-9 w-full")}</FieldContent>
- </Field>
+ <Separator />
+ <div className="flex flex-col gap-3">
+ <div>
+ <p className="text-sm font-medium text-foreground">Approval Workflow</p>
+ <p className="text-xs text-muted">
+ Configure how requests under this policy are approved.
+ </p>
</div>
- ) : (
- <ItemGroup className="max-h-[12rem] thin-scrollbar shrink-0 gap-0 overflow-y-auto rounded-lg border border-border bg-container">
- {sequenceApproversFieldArray.fields.map((el, index) => (
- <Fragment key={el.id}>
- {index > 0 && <ItemSeparator className="m-0" />}
- <Item
- onDragOver={(e) => handleDragOver(e, index)}
- onDrop={handleDrop}
- className={twMerge(
- "rounded-none border-0",
- dragOverItem === index && "bg-container-hover",
- draggedItem === index && "opacity-50"
- )}
- >
- <ItemMedia>
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton
- type="button"
- draggable
- aria-label={`Reorder step ${index + 1}`}
- variant="ghost-muted"
- size="xs"
- onDragStart={(e) => handleDragStart(e, index)}
- onDragEnd={handleDragEnd}
- onKeyDown={(event) => handleReorderKeyDown(event, index)}
- className="cursor-move"
- >
- <GripVerticalIcon />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Drag or use arrow keys to reorder</TooltipContent>
- </Tooltip>
- <Badge variant="neutral">Step {index + 1}</Badge>
- </ItemMedia>
- <ItemContent className="min-w-0">
- {renderApproverSelect(index)}
+ <Controller
+ control={control}
+ name="isDelegated"
+ render={({ field: { value, onChange } }) => (
+ <Tabs
+ value={value ? "external" : "infisical"}
+ onValueChange={(next) => handleWorkflowChange(next === "external", onChange)}
+ >
+ <TabsList variant="filled" className="w-full" aria-label="Approval workflow">
+ <TabsTrigger value="infisical">Infisical</TabsTrigger>
+ <TabsTrigger value="external" disabled={isLegacyApprovalPolicy}>
+ External Approval System
+ </TabsTrigger>
+ </TabsList>
+ </Tabs>
+ )}
+ />
+ <p className="text-xs text-muted">{getWorkflowDescription()}</p>
+ </div>
+ </>
+ )}
+ {isDelegatedMode ? (
+ <DelegatedApprovalFields control={control} watch={watch} setValue={setValue} />
+ ) : (
+ <>
+ <div>
+ <p className="text-sm font-medium text-foreground">Approvers</p>
+ <p className="text-xs text-muted">
+ Select readable members or groups, or enter an exact project member email.
+ </p>
+ </div>
+ {isAccessPolicyType ? (
+ <>
+ {sequenceApproversFieldArray.fields.length === 1 ? (
+ <div className="flex items-start gap-3">
+ <Field className="min-w-0 flex-1">
+ <FieldLabel>Approvers</FieldLabel>
+ <FieldContent>
+ {renderApproverSelect(0)}
<FieldError
errors={[
- errors.sequenceApprovers?.[index]?.user,
- errors.sequenceApprovers?.[index]?.group
+ errors.sequenceApprovers?.[0]?.user,
+ errors.sequenceApprovers?.[0]?.group
]}
/>
- </ItemContent>
- <ItemActions>
- <div className="flex items-center gap-1.5">
- <span className="text-xs text-muted">Min</span>
- {renderMinApprovals(index, "h-8 w-14")}
- </div>
- <Tooltip>
- <TooltipTrigger asChild>
- <IconButton
- aria-label="Remove step"
- variant="ghost"
- size="xs"
- onClick={() => sequenceApproversFieldArray.remove(index)}
- className="text-danger hover:text-danger"
- >
- <Trash2Icon />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Remove Step</TooltipContent>
- </Tooltip>
- </ItemActions>
- </Item>
- </Fragment>
- ))}
- </ItemGroup>
- )}
- <div>
- <Button
- size="xs"
- variant="outline"
- type="button"
- onClick={() =>
- sequenceApproversFieldArray.append({
- approvals: 1,
- user: [],
- group: []
- })
- }
- >
- <PlusIcon />
- Add Step
- </Button>
- <FieldError errors={[errors.sequenceApprovers]} />
- </div>
- </>
- ) : (
- <Field>
- <FieldLabel>Approvers</FieldLabel>
- <FieldContent>
- <Combobox
- multiple
- aria-label="Approvers"
- placeholder="Select approvers or enter a member email..."
- options={approverOptions}
- getOptionValue={getApproverOptionValue}
- getOptionLabel={getApproverOptionLabel}
- getOptionKeywords={getApproverOptionKeywords}
- renderOption={renderApproverOption}
- isOptionDisabled={(option) =>
- option.type === ApproverType.User && option.isOrgMembershipActive === false
- }
- value={selectedPolicyApprovers}
- onValueChange={updatePolicyApprovers}
- creation={{
- isValid: (input, { options, selectedOptions }) =>
- canAddMemberEmail(input, [...selectedOptions, ...options]),
- isDuplicate: () => false,
- formatLabel: (input) =>
- formatMemberEmailCreateLabel(input, [
- ...selectedPolicyApprovers,
- ...approverOptions
- ]),
- emptyLabel: MEMBER_EMAIL_HINT,
- onCreate: (input) =>
- updatePolicyApprovers([
- ...selectedPolicyApprovers,
- getManualMemberOption(input, ApproverType.User)
- ])
- }}
- isError={Boolean(errors.userApprovers || errors.groupApprovers)}
- />
- <FieldError errors={[errors.userApprovers, errors.groupApprovers]} />
- </FieldContent>
- </Field>
- )}
- <Controller
- control={control}
- name="allowedSelfApprovals"
- defaultValue
- render={({ field: { value, onChange } }) => (
- <Field orientation="horizontal">
- <FieldContent>
- <FieldTitle>Self Approvals</FieldTitle>
- <FieldDescription>Allow approvers to review their own requests</FieldDescription>
- </FieldContent>
- <Toggle
- id="self-approvals"
- aria-label="Allow self approvals"
- variant="project"
- checked={value}
- onCheckedChange={onChange}
- />
- </Field>
- )}
- />
- {!isAccessPolicyType && (
- <Controller
- control={control}
- name="bypassForMachineIdentities"
- render={({ field: { value, onChange } }) => (
- <Field orientation="horizontal">
+ </FieldContent>
+ </Field>
+ <Field className="w-28">
+ <FieldLabel>Min. Approvals</FieldLabel>
+ <FieldContent>{renderMinApprovals(0, "h-9 w-full")}</FieldContent>
+ </Field>
+ </div>
+ ) : (
+ <ItemGroup className="max-h-[12rem] thin-scrollbar shrink-0 gap-0 overflow-y-auto rounded-lg border border-border bg-container">
+ {sequenceApproversFieldArray.fields.map((el, index) => (
+ <Fragment key={el.id}>
+ {index > 0 && <ItemSeparator className="m-0" />}
+ <Item
+ onDragOver={(e) => handleDragOver(e, index)}
+ onDrop={handleDrop}
+ className={twMerge(
+ "rounded-none border-0",
+ dragOverItem === index && "bg-container-hover",
+ draggedItem === index && "opacity-50"
+ )}
+ >
+ <ItemMedia>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <IconButton
+ type="button"
+ draggable
+ aria-label={`Reorder step ${index + 1}`}
+ variant="ghost-muted"
+ size="xs"
+ onDragStart={(e) => handleDragStart(e, index)}
+ onDragEnd={handleDragEnd}
+ onKeyDown={(event) => handleReorderKeyDown(event, index)}
+ className="cursor-move"
+ >
+ <GripVerticalIcon />
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent>Drag or use arrow keys to reorder</TooltipContent>
+ </Tooltip>
+ <Badge variant="neutral">Step {index + 1}</Badge>
+ </ItemMedia>
+ <ItemContent className="min-w-0">
+ {renderApproverSelect(index)}
+ <FieldError
+ errors={[
+ errors.sequenceApprovers?.[index]?.user,
+ errors.sequenceApprovers?.[index]?.group
+ ]}
+ />
+ </ItemContent>
+ <ItemActions>
+ <div className="flex items-center gap-1.5">
+ <span className="text-xs text-muted">Min</span>
+ {renderMinApprovals(index, "h-8 w-14")}
+ </div>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <IconButton
+ aria-label="Remove step"
+ variant="ghost"
+ size="xs"
+ onClick={() => sequenceApproversFieldArray.remove(index)}
+ className="text-danger hover:text-danger"
+ >
+ <Trash2Icon />
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent>Remove Step</TooltipContent>
+ </Tooltip>
+ </ItemActions>
+ </Item>
+ </Fragment>
+ ))}
+ </ItemGroup>
+ )}
+ <div>
+ <Button
+ size="xs"
+ variant="outline"
+ type="button"
+ onClick={() =>
+ sequenceApproversFieldArray.append({
+ approvals: 1,
+ user: [],
+ group: []
+ })
+ }
+ >
+ <PlusIcon />
+ Add Step
+ </Button>
+ <FieldError errors={[errors.sequenceApprovers]} />
+ </div>
+ </>
+ ) : (
+ <Field>
+ <FieldLabel>Approvers</FieldLabel>
<FieldContent>
- <CreatableSelect<ApproverOptionData>
- isMulti
- <FieldTitle>Bypass Approval for Machine Identities</FieldTitle>
- <FieldDescription>
- When enabled, machine identities can modify secrets without requiring approval
- </FieldDescription>
++ <Combobox
++ multiple
+ aria-label="Approvers"
+ placeholder="Select approvers or enter a member email..."
+ options={approverOptions}
+ getOptionValue={getApproverOptionValue}
+ getOptionLabel={getApproverOptionLabel}
- filterOption={filterApproverOption}
- formatOptionLabel={formatApproverOptionLabel}
- formatCreateLabel={(input) => `Use member email “${input.trim()}”`}
- isValidNewOption={(input, value) =>
- canAddMemberEmail(input, [
- ...(value as MultiValue<ApproverOptionData>),
- ...approverOptions
- ])
- }
++ getOptionKeywords={getApproverOptionKeywords}
++ renderOption={renderApproverOption}
+ isOptionDisabled={(option) =>
+ option.type === ApproverType.User && option.isOrgMembershipActive === false
+ }
+ value={selectedPolicyApprovers}
- onChange={(newValue) =>
- updatePolicyApprovers([...(newValue as MultiValue<ApproverOptionData>)])
- }
- onCreateOption={(input) =>
- updatePolicyApprovers([
- ...selectedPolicyApprovers,
- getManualMemberOption(input, ApproverType.User)
- ])
- }
- noOptionsMessage={() => "Enter an exact project member email address."}
++ onValueChange={updatePolicyApprovers}
++ creation={{
++ isValid: (input, { options, selectedOptions }) =>
++ canAddMemberEmail(input, [...selectedOptions, ...options]),
++ isDuplicate: () => false,
++ formatLabel: (input) =>
++ formatMemberEmailCreateLabel(input, [
++ ...selectedPolicyApprovers,
++ ...approverOptions
++ ]),
++ emptyLabel: MEMBER_EMAIL_HINT,
++ onCreate: (input) =>
++ updatePolicyApprovers([
++ ...selectedPolicyApprovers,
++ getManualMemberOption(input, ApproverType.User)
++ ])
++ }}
+ isError={Boolean(errors.userApprovers || errors.groupApprovers)}
+ />
+ <FieldError errors={[errors.userApprovers, errors.groupApprovers]} />
</FieldContent>
- <Toggle
- id="bypass-machine-identities"
- aria-label="Bypass approval for machine identities"
- variant="project"
- checked={value}
- onCheckedChange={onChange}
- />
</Field>
)}
- />
- )}
- <Controller
- control={control}
- name="enforcementLevel"
- defaultValue={EnforcementLevel.Hard}
- render={({ field: { value, onChange } }) => (
- <Field orientation="horizontal">
- <FieldContent>
- <FieldTitle>Bypass Approvals</FieldTitle>
- <FieldDescription>
- Allow certain users to bypass policy in break-glass situations
- </FieldDescription>
- </FieldContent>
- <Toggle
- id="bypass-approvals"
- aria-label="Allow approval bypass"
- variant="project"
- checked={value === EnforcementLevel.Soft}
- onCheckedChange={(v) => onChange(v ? EnforcementLevel.Soft : EnforcementLevel.Hard)}
+ <Controller
+ control={control}
+ name="allowedSelfApprovals"
+ defaultValue
+ render={({ field: { value, onChange } }) => (
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldTitle>Self Approvals</FieldTitle>
+ <FieldDescription>
+ Allow approvers to review their own requests
+ </FieldDescription>
+ </FieldContent>
+ <Toggle
+ id="self-approvals"
+ aria-label="Allow self approvals"
+ variant="project"
+ checked={value}
+ onCheckedChange={onChange}
+ />
+ </Field>
+ )}
+ />
+ {!isAccessPolicyType && (
+ <Controller
+ control={control}
+ name="bypassForMachineIdentities"
+ render={({ field: { value, onChange } }) => (
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldTitle>Bypass Approval for Machine Identities</FieldTitle>
+ <FieldDescription>
+ When enabled, machine identities can modify secrets without requiring
+ approval
+ </FieldDescription>
+ </FieldContent>
+ <Toggle
+ id="bypass-machine-identities"
+ aria-label="Bypass approval for machine identities"
+ variant="project"
+ checked={value}
+ onCheckedChange={onChange}
+ />
+ </Field>
+ )}
/>
- </Field>
- )}
- />
- {enforcementLevel === EnforcementLevel.Soft && (
- <>
- <Field>
- <FieldLabel>Bypassers</FieldLabel>
- <FieldContent>
- <Combobox
- multiple
- aria-label="Bypassers"
- placeholder="Select bypassers or enter a member email..."
- options={bypasserOptions}
- getOptionValue={getApproverOptionValue}
- getOptionLabel={getApproverOptionLabel}
- getOptionKeywords={getApproverOptionKeywords}
- renderOption={renderApproverOption}
- isOptionDisabled={(option) =>
- option.type === BypasserType.User && option.isOrgMembershipActive === false
- }
- value={selectedPolicyBypassers}
- onValueChange={updatePolicyBypassers}
- creation={{
- isValid: (input, { options, selectedOptions }) =>
- canAddMemberEmail(input, [...selectedOptions, ...options]),
- isDuplicate: () => false,
- formatLabel: (input) =>
- formatMemberEmailCreateLabel(input, [
- ...selectedPolicyBypassers,
- ...bypasserOptions
- ]),
- emptyLabel: MEMBER_EMAIL_HINT,
- onCreate: (input) =>
- updatePolicyBypassers([
- ...selectedPolicyBypassers,
- getManualMemberOption(input, BypasserType.User)
- ])
- }}
- isError={Boolean(errors.userBypassers || errors.groupBypassers)}
- />
- <FieldError errors={[errors.userBypassers, errors.groupBypassers]} />
- </FieldContent>
- </Field>
+ )}
+ <Controller
+ control={control}
+ name="enforcementLevel"
+ defaultValue={EnforcementLevel.Hard}
+ render={({ field: { value, onChange } }) => (
+ <Field orientation="horizontal">
+ <FieldContent>
+ <FieldTitle>Bypass Approvals</FieldTitle>
+ <FieldDescription>
+ Allow certain users to bypass policy in break-glass situations
+ </FieldDescription>
+ </FieldContent>
+ <Toggle
+ id="bypass-approvals"
+ aria-label="Allow approval bypass"
+ variant="project"
+ checked={value === EnforcementLevel.Soft}
+ onCheckedChange={(v) =>
+ onChange(v ? EnforcementLevel.Soft : EnforcementLevel.Hard)
+ }
+ />
+ </Field>
+ )}
+ />
+ {enforcementLevel === EnforcementLevel.Soft && (
+ <>
+ <Field>
+ <FieldLabel>Bypassers</FieldLabel>
+ <FieldContent>
- <CreatableSelect<ApproverOptionData>
- isMulti
++ <Combobox
++ multiple
+ aria-label="Bypassers"
+ placeholder="Select bypassers or enter a member email..."
+ options={bypasserOptions}
+ getOptionValue={getApproverOptionValue}
+ getOptionLabel={getApproverOptionLabel}
- filterOption={filterApproverOption}
- formatOptionLabel={formatApproverOptionLabel}
- formatCreateLabel={(input) => `Use member email “${input.trim()}”`}
- isValidNewOption={(input, value) =>
- canAddMemberEmail(input, [
- ...(value as MultiValue<ApproverOptionData>),
- ...bypasserOptions
- ])
- }
++ getOptionKeywords={getApproverOptionKeywords}
++ renderOption={renderApproverOption}
+ isOptionDisabled={(option) =>
+ option.type === BypasserType.User && option.isOrgMembershipActive === false
+ }
+ value={selectedPolicyBypassers}
- onChange={(newValue) =>
- updatePolicyBypassers([...(newValue as MultiValue<ApproverOptionData>)])
- }
- onCreateOption={(input) =>
- updatePolicyBypassers([
- ...selectedPolicyBypassers,
- getManualMemberOption(input, BypasserType.User)
- ])
- }
- noOptionsMessage={() => "Enter an exact project member email address."}
++ onValueChange={updatePolicyBypassers}
++ creation={{
++ isValid: (input, { options, selectedOptions }) =>
++ canAddMemberEmail(input, [...selectedOptions, ...options]),
++ isDuplicate: () => false,
++ formatLabel: (input) =>
++ formatMemberEmailCreateLabel(input, [
++ ...selectedPolicyBypassers,
++ ...bypasserOptions
++ ]),
++ emptyLabel: MEMBER_EMAIL_HINT,
++ onCreate: (input) =>
++ updatePolicyBypassers([
++ ...selectedPolicyBypassers,
++ getManualMemberOption(input, BypasserType.User)
++ ])
++ }}
+ isError={Boolean(errors.userBypassers || errors.groupBypassers)}
+ />
+ <FieldError errors={[errors.userBypassers, errors.groupBypassers]} />
+ </FieldContent>
+ </Field>
- {bypasserCount <= 0 && (
- <Alert variant="warning">
- <TriangleAlertIcon />
- <AlertDescription>
- {isAccessPolicyType && allowedSelfApprovals === false
- ? "Self approvals are off, so nobody can bypass this policy until you select bypassers."
- : "Not selecting specific users or groups will allow anyone to bypass this policy."}
- </AlertDescription>
- </Alert>
+ {bypasserCount <= 0 && (
+ <Alert variant="warning">
+ <TriangleAlertIcon />
+ <AlertDescription>
+ {isAccessPolicyType && allowedSelfApprovals === false
+ ? "Self approvals are off, so nobody can bypass this policy until you select bypassers."
+ : "Not selecting specific users or groups will allow anyone to bypass this policy."}
+ </AlertDescription>
+ </Alert>
+ )}
+ </>
)}
</>
)}