Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Merge branch 'main' into feat/adilsitos/secrets-722
adilson8de9291ae8f1
diff --cc backend/src/services/approval-policy/approval-policy-types.tsindex 0dc08fa359,61b0ba933e..4897e9ec25--- a/backend/src/services/approval-policy/approval-policy-types.ts+++ b/backend/src/services/approval-policy/approval-policy-types.ts@@@ -1,14 -1,23 +1,30 @@@import { Knex } from "knex";+import { TApprovalPolicies, TApprovalRequestGrants } from "@app/db/schemas";+import { TAdditionalPrivilegeDALFactory } from "@app/services/additional-privilege/additional-privilege-dal";+import { TApprovalPolicyDALFactory } from "@app/services/approval-policy/approval-policy-dal";+import { TApprovalRequestGrantsDALFactory } from "@app/services/approval-policy/approval-request-dal";+import { ActorAuthMethod, ActorType } from "@app/services/auth/auth-type";+import { TCertificateRequestDALFactory } from "@app/services/certificate-request/certificate-request-dal";+import { TCertificateApprovalService } from "@app/services/certificate-v3/certificate-approval-fns";+ import { TApprovalPolicies, TApprovalRequestGrants, TApprovalRequests } from "@app/db/schemas";+ import { Event } from "@app/ee/services/audit-log/audit-log-types";+ import { ResourcePermissionApprovalPolicyActions } from "@app/ee/services/permission/resource-permission";+ import { OrgServiceActor } from "@app/lib/types";+ import { TNotification } from "@app/lib/workflow-integrations/types";+ import { NotificationType } from "@app/services/notification/notification-types";+ import { SmtpTemplates } from "@app/services/smtp/smtp-service";+ import { TPostHogEvent } from "@app/services/telemetry/telemetry-types";- import { ApprovalPolicyScope, ApprovalPolicyType, ApproverType, EnforcementLevel } from "./approval-policy-enums";+ import {+ ApprovalAuditAction,+ ApprovalNotificationEvent,+ ApprovalPolicyScope,+ ApprovalPolicyType,+ ApprovalRequestApprovalDecision,+ ApproverType,+ EnforcementLevel+ } from "./approval-policy-enums";import {TCertRequestPolicy,TCertRequestPolicyConditions,@@@ -33,21 -42,13 +49,27 @@@ importTPamAccessRequest,TPamAccessRequestData} from "./pam-access/pam-access-policy-types";-+import {+ TSecretAccessPolicy,+ TSecretAccessPolicyConditions,+ TSecretAccessPolicyConstraints,+ TSecretAccessPolicyInputs,+ TSecretAccessRequest,+ TSecretAccessRequestData+} from "./secret-access/secret-access-policy-types";++export type TApprovalPolicy = TPamAccessPolicy | TCertRequestPolicy | TCodeSigningPolicy | TSecretAccessPolicy;+export type TApprovalPolicyInputs =+ | TPamAccessPolicyInputs+ | TCertRequestPolicyInputs+ | TCodeSigningPolicyInputs+ | TSecretAccessPolicyInputs;+ export type TApprovalActor = Pick<OrgServiceActor, "id" | "type" | "authMethod" | "orgId">;++ export type TApprovalSubjectActor = Pick<TApprovalActor, "id" | "type">;++ export type TApprovalPolicy = TPamAccessPolicy | TCertRequestPolicy | TCodeSigningPolicy;+ export type TApprovalPolicyInputs = TPamAccessPolicyInputs | TCertRequestPolicyInputs | TCodeSigningPolicyInputs;export type TApprovalPolicyConditions =| TPamAccessPolicyConditions| TCertRequestPolicyConditions@@@ -152,59 -148,158 +175,185 @@@ export interface TCreateRequestFromPolitx?: Knex;}+// Factory+export type TApprovalRequestFactoryMatchPolicy<I extends TApprovalPolicyInputs, P extends TApprovalPolicy> = (+ approvalPolicyDAL: TApprovalPolicyDALFactory,+ projectId: string,+ inputs: I+) => Promise<P | null>;+export type TApprovalRequestFactoryCanAccess<I extends TApprovalPolicyInputs> = (+ approvalRequestGrantsDAL: TApprovalRequestGrantsDALFactory,+ projectId: string,+ userId: string,+ inputs: I+) => Promise<TApprovalRequestGrants | null>;+export type TApprovalRequestFactoryValidateConstraints<P extends TApprovalPolicy, R extends TApprovalRequestData> = (+ policy: P,+ inputs: R+) => { valid: boolean; errors?: string[] };++export type TPostApprovalContext = {+ actor?: {+ type: ActorType;+ id: string;+ authMethod: ActorAuthMethod;+ orgId: string;+ };+ certificateApprovalService?: TCertificateApprovalService;+ certificateRequestDAL?: Pick<TCertificateRequestDALFactory, "updateById" | "findById">;+ additionalPrivilegeDAL?: Pick<TAdditionalPrivilegeDALFactory, "create">;+ export type TApprovalNotification = {+ inApp?: { type: NotificationType; title: string; body: string; link?: string };+ email?: { subjectLine: string; template: SmtpTemplates; substitutions: Record<string, unknown> };+ chat?: { workflowIntegrationId: string; channelIds: string[]; notification: TNotification }[];};- export type TApprovalRequestFactoryPostApprovalRoutine<C extends TPostApprovalContext = TPostApprovalContext> = (- approvalRequestGrantsDAL: TApprovalRequestGrantsDALFactory,- request: TApprovalRequest,- context: C- ) => Promise<void>;-- export type TApprovalRequestFactoryPostRejectionRoutine<C extends TPostApprovalContext = TPostApprovalContext> = (- request: TApprovalRequest,- context: C- ) => Promise<void>;-- export type TApprovalResourceFactory<- I extends TApprovalPolicyInputs,- P extends TApprovalPolicy,- R extends TApprovalRequestData,- C extends TPostApprovalContext = TPostApprovalContext- > = (policyType: ApprovalPolicyType) => {- matchPolicy: TApprovalRequestFactoryMatchPolicy<I, P>;- canAccess: TApprovalRequestFactoryCanAccess<I>;- validateConstraints: TApprovalRequestFactoryValidateConstraints<P, R>;- postApprovalRoutine: TApprovalRequestFactoryPostApprovalRoutine<C>;- postRejectionRoutine: TApprovalRequestFactoryPostRejectionRoutine<C>;+ // The one extension point: a policy type implements this and registers it at wiring time. Only the+ // first three members are required; everything else falls back to shared behaviour.+ export type TApprovalResource<+ I extends TApprovalPolicyInputs = TApprovalPolicyInputs,+ P extends TApprovalPolicy = TApprovalPolicy,+ R extends TApprovalRequestData = TApprovalRequestData+ > = {+ matchPolicy: (projectId: string, inputs: I) => Promise<P | null>;+ canAccess: (projectId: string, actorId: string, inputs: I) => Promise<TApprovalRequestGrants | null>;+ validateConstraints: (policy: P, requestData: R) => { valid: boolean; errors?: string[] };++ // Whatever the approval entitles the requester to goes in the Tx variant, which commits with the+ // approval; anything reaching outside the database goes in postApprovalRoutine, after the commit.+ postApprovalTxRoutine?: (+ request: TApprovalRequest,+ tx: Knex,+ breakGlass?: { bypassReason: string }+ ) => Promise<{ grantId: string } | void>;+ postApprovalRoutine?: (request: TApprovalRequest, actor?: TApprovalActor) => Promise<void>;+ postRejectionRoutine?: (request: TApprovalRequest) => Promise<void>;++ // Whether a stored grant's attributes or a request's payload is for the thing these inputs name.+ // Without it the access-status and reaping helpers have nothing to match on.+ matchesInputs?: (payload: unknown, inputs: TApprovalPolicyInputs) => boolean;++ // The product analytics a lifecycle action owes, so the shared route does not have to know which+ // products it is serving. Returning nothing records nothing.+ buildTelemetryEvent?: (args: {+ action: ApprovalAuditAction;+ request: TApprovalRequests;+ distinctId: string;+ decision?: string;+ }) => Promise<TPostHogEvent | null>;++ // Whether the actor is still an approver for the scope, for a type where the request's creation-time+ // approver snapshot can outlive the membership behind it.+ isLiveApprover?: (args: {+ projectId: string;+ scopeId: string;+ actor: TApprovalActor;+ userGroupIds: Set<string>;+ }) => Promise<boolean>;++ // The audit event a lifecycle action owes. A type whose auditors filter on resource ids contributes+ // its own event here; returning nothing leaves the generic approval event in place.+ buildAuditEvent?: (args: {+ action: ApprovalAuditAction;+ request: TApprovalRequests;+ grantId?: string;+ actorId: string;+ comment?: string;+ bypassReason?: string;+ }) => Promise<Event | null>;++ // Copy and chat routing for a lifecycle event. Returning nothing sends nothing.+ buildNotification?: (args: {+ event: ApprovalNotificationEvent;+ request: TApprovalRequests;+ comment?: string;+ bypassReason?: string;+ }) => Promise<TApprovalNotification | null>;+ // Narrows the notified approvers to those still eligible, for a type where an approver row can+ // outlive the membership behind it.+ filterActiveApprovers?: (+ request: TApprovalRequests,+ approvers: { type: ApproverType; id: string }[]+ ) => Promise<{ type: ApproverType; id: string }[]>;++ // Scope and authorization the service cannot work out on its own. Without these it resolves project+ // and application scopes itself, authorizes policy CRUD against project admin, and requires+ // approvers to be project members.+ resolveScope?: (scopeId: string) => Promise<{ projectId: string }>;+ // The default reads as an invitation to go ahead, which is wrong where an unconfigured scope is a+ // misconfiguration to report.+ noMatchingPolicyMessage?: string;+ assertCanManagePolicy?: (args: {+ projectId: string;+ scopeId: string | null;+ actor: TApprovalActor;+ action: ResourcePermissionApprovalPolicyActions;+ }) => Promise<void>;++ // Whether the actor may read a scope's requests and grants, for a type whose read authority is the+ // scope rather than the project.+ canReadScope?: (args: { projectId: string; scopeId: string | null; actor: TApprovalActor }) => Promise<boolean>;++ // Set where a scope may carry at most one policy, so creating a second is refused rather than ignored.+ singlePolicyPerScope?: boolean;++ // The only scope this type's policies may be created against, paired with resolveScope.+ scopeType?: ApprovalPolicyScope;+ verifyPolicyActors?: (args: {+ projectId: string;+ scopeId: string | null;+ approvers: PolicyBypasser[];+ bypassers: PolicyBypasser[];+ }) => Promise<void>;+ assertCanCreateRequest?: (args: {+ projectId: string;+ policy: TApprovalPolicy;+ requestData: TApprovalRequestData;+ actor: TApprovalActor;+ }) => Promise<void>;+ assertCanReview?: (args: {+ request: TApprovalRequests;+ decision: ApprovalRequestApprovalDecision;+ actor: TApprovalActor;+ userGroupIds: Set<string>;+ }) => Promise<void>;+ // The default treats an empty bypasser list as everybody; a type reading it the other way says so here.+ isBreakGlassEligible?: (args: {+ request: TApprovalRequests;+ policy: TApprovalPolicies;+ bypassers: PolicyBypasser[];+ actor: TApprovalActor;+ userGroupIds: Set<string>;+ }) => Promise<boolean>;+ assertCanRevokeGrant?: (args: {+ grant: TApprovalRequestGrants;+ request: TApprovalRequests | null;+ actor: TApprovalActor;+ }) => Promise<void>;+ // Returns the side effects to fire once the revocation is durable, so a caller inside a transaction+ // that can still roll back cuts nothing early.+ onGrantRevoked?: (args: { grant: TApprovalRequestGrants; actorId: string; tx?: Knex }) => Promise<() => void>;+ };++ export enum ApprovalAccessStatus {+ None = "none",+ Pending = "pending",+ Granted = "granted"+ }++ export type TApprovalAccessStatus = {+ accessStatus: ApprovalAccessStatus;+ grantExpiresAt: Date | null;+ pendingRequestId: string | null;};+ export type TApprovalScopeConfiguration = {+ steps: { requiredApprovals: number; approvers: PolicyBypasser[] }[];+ bypassers: PolicyBypasser[];+ };++ export type TApprovalResourceRegistry = Partial<Record<ApprovalPolicyType, TApprovalResource>>;+export type TApprovalRequestSubjectMetadata = {certificateRequestId?: string;commonName?: string;