Skip to content

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

6.1 KB
Raw Blame
export enum PamAccountType {
  SSH = "ssh",
  Postgres = "postgres",
  MySQL = "mysql",
  MsSQL = "mssql",
  OracleDB = "oracledb",
  MongoDB = "mongodb",
  Redis = "redis",
  Snowflake = "snowflake",
  ClickHouse = "clickhouse",
  Kubernetes = "kubernetes",
  AwsIam = "aws-iam",
  GcpServiceAccount = "gcp-service-account",
  AzureCli = "azure-cli",
  Windows = "windows",
  WindowsAd = "windows-ad"
}

export enum PamDiscoveryType {
  ActiveDirectory = "active-directory",
  Unix = "unix",
  Postgres = "postgres",
  MsSQL = "mssql"
}

export enum PamDiscoverySchedule {
  Manual = "manual",
  Daily = "daily",
  Weekly = "weekly"
}

export const ROTATABLE_PAM_ACCOUNT_TYPES = [
  PamAccountType.Postgres,
  PamAccountType.MySQL,
  PamAccountType.MsSQL,
  PamAccountType.OracleDB,
  PamAccountType.Windows,
  PamAccountType.WindowsAd
];

export const isRotatablePamAccountType = (type: PamAccountType | string) =>
  (ROTATABLE_PAM_ACCOUNT_TYPES as string[]).includes(type);

// Informational conditions on an account. Unlike PamAccountAccessibilityIssue these gate nothing:
// the account launches, records and rotates as normal. Mirrors PamAccountWarning in
// backend/src/ee/services/pam/pam-enums.ts.
export enum PamAccountWarning {
  SessionLogMaskingDegraded = "session-log-masking-degraded"
}

// Windows is brokered over RDP, whose recordings the gateway never masks; AWS IAM is gateway-less
// and produces no session log. Mirrors accountTypeSupportsSessionLogMasking in
// backend/src/ee/services/pam/pam-enums.ts.
export const UNMASKABLE_PAM_ACCOUNT_TYPES = [
  PamAccountType.Windows,
  PamAccountType.WindowsAd,
  PamAccountType.AwsIam
];

export const pamAccountTypeSupportsSessionLogMasking = (type: PamAccountType | string) =>
  !(UNMASKABLE_PAM_ACCOUNT_TYPES as string[]).includes(type);

// Mirrors ORACLE_MAX_PASSWORD_LENGTH in backend/src/ee/services/pam-account/pam-account-schemas.ts, which is
// what actually rejects a longer one. Change both together.
export const ORACLE_MAX_PASSWORD_LENGTH = 30;

export const maxGeneratedPasswordLength = (type: PamAccountType | string | undefined) =>
  type === PamAccountType.OracleDB ? ORACLE_MAX_PASSWORD_LENGTH : 250;

export enum PamHeartbeatStatus {
  Healthy = "healthy",
  InvalidCredentials = "invalid-credentials",
  CannotCheck = "cannot-check",
  Unknown = "unknown"
}

export enum PamRotationStatus {
  Success = "success",
  Failed = "failed"
}

export const PAM_ROTATION_INTERVAL_OPTIONS: { seconds: number; label: string }[] = [
  { seconds: 3600, label: "1 hour" },
  { seconds: 43200, label: "12 hours" },
  { seconds: 86400, label: "24 hours" },
  { seconds: 604800, label: "7 days" },
  { seconds: 2592000, label: "30 days" }
];

const INTERVAL_UNITS = [
  { size: 86400, unit: "day" },
  { size: 3600, unit: "hour" },
  { size: 60, unit: "minute" }
];

export const formatRotationInterval = (seconds: number | null | undefined): string => {
  if (seconds == null) return "Manual only";
  const preset = PAM_ROTATION_INTERVAL_OPTIONS.find((option) => option.seconds === seconds);
  if (preset) return preset.label;
  const { size, unit } = INTERVAL_UNITS.find((u) => seconds % u.size === 0) ?? {
    size: 1,
    unit: "second"
  };
  const amount = seconds / size;
  return `${amount} ${unit}${amount === 1 ? "" : "s"}`;
};

// The API accepts any interval, so a saved one may not be a preset.
export const getRotationIntervalOptions = (savedSeconds: number | null | undefined) =>
  savedSeconds == null ||
  PAM_ROTATION_INTERVAL_OPTIONS.some((option) => option.seconds === savedSeconds)
    ? PAM_ROTATION_INTERVAL_OPTIONS
    : [
        ...PAM_ROTATION_INTERVAL_OPTIONS,
        { seconds: savedSeconds, label: formatRotationInterval(savedSeconds) }
      ].sort((a, b) => a.seconds - b.seconds);

export enum PamPolicyType {
  RequiresApproval = "requires-approval",
  AllowAutoApproval = "allow-auto-approval",
  AllowBreakGlass = "allow-break-glass",
  RequireMfa = "require-mfa",
  RequireReason = "require-reason",
  MaxSessionDuration = "max-session-duration",
  CommandBlocking = "command-blocking"
}

export enum SessionChannelType {
  Terminal = "terminal",
  Exec = "exec",
  Sftp = "sftp",
  Rdp = "rdp"
}

export enum PamSessionStatus {
  Starting = "starting",
  Active = "active",
  Ended = "ended",
  Terminated = "terminated"
}

export enum PamAccountOrderBy {
  Name = "name"
}

export enum PamAccountView {
  Flat = "flat",
  Nested = "nested"
}

export enum PamResourcePermissionSub {
  PamResource = "pam-resource"
}

export enum PamResourcePermissionActions {
  ReadFolder = "read-folder",
  EditFolder = "edit-folder",
  DeleteFolder = "delete-folder",
  ReadAccounts = "read-accounts",
  CreateAccounts = "create-accounts",
  EditAccounts = "edit-accounts",
  DeleteAccounts = "delete-accounts",
  LaunchSessions = "launch-sessions",
  ViewSessions = "view-sessions",
  TerminateSessions = "terminate-sessions",
  ViewCredentials = "view-credentials",
  ApproveRequests = "approve-requests",
  RevokeGrants = "revoke-grants",
  ManagePolicies = "manage-policies",
  ManageRotation = "manage-rotation",
  ManageMembers = "manage-members",
  ViewAuditLogs = "view-audit-logs"
}

export enum PamAccessType {
  Session = "session",
  Credential = "credential"
}

// The caller's just-in-time approval state for an account gated behind an access request flow
export enum PamAccessStatus {
  None = "none",
  Pending = "pending",
  Granted = "granted"
}

export enum PamAccessRequestStatus {
  Pending = "pending",
  Approved = "approved",
  Rejected = "rejected",
  Expired = "expired",
  Cancelled = "cancelled"
}

export enum PamAccessRequestDecision {
  Approved = "approved",
  Rejected = "rejected"
}

export enum PamAccessGrantStatus {
  Active = "active",
  Expired = "expired",
  Revoked = "revoked"
}

export enum PamApproverType {
  User = "user",
  Group = "group"
}

// Mirrors PamNotificationEvent in backend/src/ee/services/pam/pam-enums.ts
export enum PamNotificationEvent {
  AccessRequested = "access-requested",
  AccessRequestApproved = "access-request-approved",
  AccessRequestDenied = "access-request-denied",
  AccessRequestBypassed = "access-request-bypassed"
}

export enum PamFolderCallerAccess {
  Admin = "admin",
  Member = "member",
  None = "none"
}