Skip to content

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

Merge branch 'main' into dimitris/overprivileged-secrets-view

DimitrisStaratzis6e716e11b379
diff --cc backend/AGENTS.md
index 081feb7cb7,59d352893f..0f6079c830
--- a/backend/AGENTS.md
+++ b/backend/AGENTS.md
@@@ -1234,109 -1274,40 +1274,143 @@@ timezone, so pin day grouping and boun
the table is a `ReplacingMergeTree`: a retried batch inserts the same `id` twice and the copy goes away
only at some later merge, so read with `FINAL` when an exact count matters.
+### Secret Read Activity
+
+`ee/services/secret-read-activity/` answers "who has read this secret" for the per-secret access sheet and
+the Insights Unused Secret Access card. It does not use audit logs: ClickHouse is optional on self-hosted
+and the events cannot say which folders a recursive read returned. Instead it keeps its own table,
+`secret_read_activity`, one row per (object, reader) holding the last read time. The write path (producer,
+stream drain and both crons) lives in `secret-read-activity-queue.ts`, like `audit-log-queue.ts`; the service
+owns the two read endpoints and hands `recordRead` / `recordBulkRead` through to the queue.
+
+- **Write path.** Read routes call `recordBulkRead` / `recordRead` with `void`, so they never fail or slow a
+ read. A bulk read that returned whole folders (no tag or metadata filter, imports and references included)
+ records its folder, plus every non-reserved subfolder when recursive, and does so even on a 304. A
+ narrower bulk read records the ids of the secrets it returned, so the secrets it left out are not credited.
+ A narrow 304 carries no secrets and records nothing, which is safe only because ETags are stored per UTC day,
+ so each client's first read of the day is a full response. Single reads record the secret. A read with
+ references unexpanded is stored as `secret-unexpanded` and credits only that secret, not the values it
+ references, which is why `objectType` is part of the primary key. A read that expands references with the reader's
+ personal overrides (v4 bulk with `includePersonalOverrides`, v4 single read of a personal secret) records the
+ returned secrets plus the ones its references resolved to, all as `secret-unexpanded`: matching references by key
+ would credit a shared secret an override replaced. The expander reports a secret's referenced ids through
+ `onSecretExpanded` only once that secret's expansion succeeds, tagged with the secret, so a failed expansion
+ credits nothing and the single read passes on only the returned secret's (imports expand every imported secret).
+ The bulk read caches them with its result (only for these reads, so every other cached payload and ETag is
+ unchanged) so a cache hit replays them. A Redis `SET NX` gate (25h TTL) keyed on
+ the reader, the day and the request (or the hash of the returned ids) lets only the first identical read
+ per day through. It is keyed on the request, not the client's ETag, since older clients never send one; a folder
+ read is also keyed on the response's ETag, so a read that returns more after an access change is recorded again
+ the same day. Gated reads go to a
+ Redis stream drained the way the audit log ingest stream is (collect, write, then trim, under a
+ non-blocking lock), by the `SecretReadActivityFlush` cron every minute into an upsert.
+- **Partitioned by month, no foreign keys, no index on `lastReadAt`.** The table is range-partitioned on
+ `readMonth` (the UTC month of `lastReadAt`, part of the primary key), so a reader has one row per month and
+ `findLastReads` folds them into the latest. The daily `SecretReadActivityPrune` cron creates the current and
+ next three months' partitions and drops a month once all of it is older than the 30-day window, since nothing
+ reads before it. Never prune with `DELETE`: at this table's size that is a full scan plus vacuum. Partition DDL
+ takes an exclusive lock on the whole table, so it runs under a short `lock_timeout` and retries on the next run.
+ Partitions use `fillfactor = 90` and `lastReadAt` is in no index, which together keep the upsert a HOT update.
+ Rows of deleted objects age out with their month. A move creates new ids, so the window
+ starts no earlier than the secret's and its folder's creation (`trackedSince`), nor before the table existed.
+- **Read path.** A read counts when it reaches the secret through its folder, an import of it, a secret
+ referencing it, or the source of a replication import (imports and references check the reader's own access
+ to the source, so revoking it would break them). A personal secret referencing it counts only when the personal secret
+ itself is read, not its folder (a read without overrides leaves personal values out), and nothing referencing the
+ personal secret is followed: a reference resolves to the shared secret without overrides. The card computes the whole project once and caches it
+ (`KeyStoreTtls.InsightsUnusedAccessCacheInSeconds`), grouping actors by identical rules so each rule set is checked once
+ per secret. The per-secret endpoint checks the caller's access to the secret before building its reach, which
+ decrypts every secret that could reference it.
+- **Only a full window is judged.** Tracking starts at the later of the migration that created the table and the
+ project's creation, and reads from before it are unknown, so nothing counts as unused access until tracking has run
+ 30 days (`getUnusedAccessFrom`). `judgedFrom` is always the start of the last 30 days, and a secret's `trackedSince`
+ starts no earlier than tracking did, so before then no secret covers the window; the card skips the scan and
+ caches nothing, and the access sheet gives the `tracking-too-new` reason. Every response carries `unusedAccessFrom`
+ so the UI can say when results start. The card leaves out project admins (users
+ and identities with the Admin role, directly or through a group, from `findAdminActorIds`): they can read
+ everything by design. Their reads are still recorded, so the access sheet's Last Read stays true for them. A
+ pair is listed once the secret (`trackedSince`) and the actor's access to that secret both predate `judgedFrom`.
+ Access is dated per secret (`createAccessDating`): each actor's sources (every role assignment and project-wide
+ privilege, from `getProjectPermissions`' `accessSources`; each group they are in, from `permissionForActor` with
+ `groupsOnly` so placeholders hold the member's details; each folder grant) carry the date
+ `findAccessSourceDates` gives them, and a secret's access dates from the oldest source that grants it on its own,
+ so a change only restarts the window for the secrets it opened. An edit to a custom role's rules dates that role
+ for every secret it gives, since which secrets an edit opened is not recorded. Expired access is not a source, but
+ an ended restriction may have given access back, so access dates no earlier than an expired folder grant in its
+ folder, a folder grant edited since its creation in its folder, or an expired temporary role or privilege across
+ all of its holder's access (what it held back is not worked out). Only the current secret's source checks are
+ kept, so the scan's memory does not grow with the project. Only an actor with a
+ source newer than `judgedFrom` is checked per secret, and each source once per secret across actors. A read from
+ before the reader had access to a secret is dropped for that secret (`readsByActorId`): reads are credited by
+ folder, and a folder read then could not have returned it. A read recorded against the secret itself
+ (`lastSecretReadAt`) always counts, so a role change does not erase it. The per-secret sheet shows the plain fact
+ instead: a read, "No reads", or "No reads yet" with the reason.
+- **The access sheet.** The graph lives only in the secret's access sheet, served by
+ `GET /insights/:projectId/secrets/read-activity/:secretName` (the fixed segment comes first so a secret named
+ `reports` or `summary` cannot hit those routes). It returns `actors`: everyone who can read the value, admins
+ included, each with `lastReadAt`, `isProjectAdmin`, `accessSince`, and a `readStatus` (`read`, `unused`,
+ `not-judged`) with a `notJudgedReason` (`project-admin`, `access-too-new`, `secret-too-new`) from
+ `getReadStatus`. The API returns codes and dates only; the UI writes the wording. Readers who lost access
+ ("ghost readers") are not computed or returned.
+- **The Insights card is per actor** (a user or machine identity; a group is never a row, only an access path).
+ `summarizeSecretAccess` (in `secret-read-activity-fns.ts`) is the one place a secret's readers and unread readers
+ are derived, from the project's access loaded once by `$loadProjectAccess`; both the per-secret
+ endpoint and the project scan use it. `$tallyUnusedAccess` scans every secret once and tallies, per actor, how many
+ secrets it can read, how many it has not read and the environments involved; `$computeUnusedAccess`
+ ranks the tallies into rows (`accessibleSecretCount`, `unusedSecretCount`). Each row carries `accessPaths` as data: `roles` it holds directly (`id`/`slug`/`name`,
+ where a custom role has the slug `custom` and its own id), `groups` it belongs to with the roles each one gives,
+ `additionalPrivileges` as `id`/`name` (project-wide only), and `folderAccess`: the actor's own active folder grants
+ (`id`/`folderId`/`environment`/`secretPath`/`role`). A folder grant is stored as an additional privilege with a
+ `folderId`, which the member listings filter out, so `getProjectPermissions` returns them as
+ `folderAccessByActorId` from the grants it already loads. The UI decides how to label all of them. Custom role ids and names come from
+ `getProjectPermissions`, so the scan makes no role lookup of its own. Each person is checked with one permission merged across their direct membership and every group
+ they are in (`getProjectPermissions().permissionForActor`, built from getProjectPermission's own steps by
+ `buildMergedProjectPermissionRules`), so a deny in one role holds against an allow in another, and placeholders
+ such as `{{identity.username}}` are filled from that person's details (looked up for group-only members only
+ when a group role holds one). It
+ is cached per project for a day (`insights-cache:<projectId>:unused-access`, under a per-project lock on a cold
+ cache): every actor's row, plus the unread secret ids for the 200 actors with the most, capped at 200 each; an
+ actor past that is scanned for alone when opened and cached per actor. Served by
+ `GET /insights/:projectId/secrets/unused-access` (ranked by unread count, searchable by name) and
+ `/unused-access/:actorType/:actorId` (`user` or `identity`), whose secrets go through a per-caller DescribeSecret
+ recheck. The audit event keeps `principalType`/`principalId`/`principalName` for the viewed actor, so they do not
+ read as the event's own actor. The scans are synchronous CPU work, so they `await setImmediate()` (from
+ `node:timers/promises`) between secrets to let other requests on the instance run.
+
+ ### Free Text in Audit Events
+
+ A name, reason, comment or justification can carry ANSI escapes, bidi overrides or zero-width
+ characters. They are valid JSON but rewrite a terminal line, reorder text in a SIEM, or make two values
+ look identical. Two layers handle them, both built on `src/lib/validator/log-safe-text.ts`:
+
+ - **The route rejects them.** Wrap any free-text field that reaches an audit event in `auditSafeText`
+ (`src/server/lib/schemas.ts`), so the caller gets a 422 naming the problem and can fix the input:
+
+ ```ts
+ name: auditSafeText(z.string().trim().min(1).max(255)),
+ reason: auditSafeText(z.string().trim().max(500), { allowMultiline: true }).optional(),
+ ```
+
+ - **The sink strips them.** `audit-log-queue.ts` runs actor and event metadata through
+ `sanitizeLogPayload` and `ipAddress`, `userAgent` and `projectName` through `sanitizeLogText`. They
+ strip control, ANSI, bidi and zero-width characters, turn CR and U+2028/U+2029 into LF, drop lone
+ surrogates (Postgres jsonb rejects them, failing the whole batch), and suffix metadata keys that
+ collide after cleaning (`email~2`) instead of dropping one. This covers what the API cannot reject
+ (IdP claims, user agents, legacy rows), so do not strip values yourself before logging.
+
+ Rules for the route check:
+
+ - **`allowMultiline: true` for textarea fields** (reasons, comments, justifications). It keeps tab, LF
+ and CR; single-line fields reject them.
+ - **Keep the bound inside the wrapper.** `auditSafeText` takes a `ZodString`, so `.max()`, `.trim()` and
+ `.min()` go on the inner schema and `.optional()`, `.nullable()` and `.describe()` go outside.
+ - **Only validate a value the caller is setting.** A schema check on an editable field blocks every edit
+ of a row that already holds a legacy value, because clients resend the whole body. For updates, check
+ in the service with `containsLogUnsafeCharacters` and `LOG_UNSAFE_TEXT_MESSAGE`, and only when the
+ value differs from the stored one, as `identity-service.ts` and `project-template-service.ts` do.
+ Write-once fields (approval comments, justifications, break-glass reasons) can use the schema directly.
+ - **Never put it on a response schema.** Stored rows predate the check and would fail serialization.
+
### Audit Log Event Classes and Settings
Every `EventType` belongs to exactly one class in
diff --cc backend/src/@types/fastify.d.ts
index 980dba85ff,c37c95ab0b..e3a25df0e7
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@@ -73,9 -73,7 +73,8 @@@ import { TScimServiceFactory } from "@a
import { TSecretApprovalPolicyServiceFactory } from "@app/ee/services/secret-approval-policy/secret-approval-policy-service";
import { TSecretApprovalRequestServiceFactory } from "@app/ee/services/secret-approval-request/secret-approval-request-service";
import { TSecretChangeGlobalPolicyBridgeServiceFactory } from "@app/ee/services/secret-change-global-policy-bridge/secret-change-global-policy-bridge-service";
+import { TSecretReadActivityServiceFactory } from "@app/ee/services/secret-read-activity/secret-read-activity-service";
import { TSecretRotationV2ServiceFactory } from "@app/ee/services/secret-rotation-v2/secret-rotation-v2-service";
- import { TSecretScanningServiceFactory } from "@app/ee/services/secret-scanning/secret-scanning-service";
import { TSecretScanningV2InstanceServiceFactory } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-instance-service";
import { TSecretScanningV2ProjectResolverFactory } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-project-resolver";
import { TSecretScanningV2ServiceFactory } from "@app/ee/services/secret-scanning-v2/secret-scanning-v2-service";
@@@ -306,206 -308,214 +309,215 @@@ declare module "fastify"
interface FastifyInstance {
redis: Redis | Cluster;
cookieSigningKey: string;
- services: {
- login: TAuthLoginFactory;
- password: TAuthPasswordFactory;
- accountRecovery: TAccountRecoveryServiceFactory;
- signup: TAuthSignupFactory;
- authToken: TAuthTokenServiceFactory;
- oauthClient: TOauthClientServiceFactory;
- permission: TPermissionServiceFactory;
- org: TOrgServiceFactory;
- oidc: TOidcConfigServiceFactory;
- superAdmin: TSuperAdminServiceFactory;
- encryptionKeyRotation: TEncryptionKeyRotationServiceFactory;
- user: TUserServiceFactory;
- group: TGroupServiceFactory;
- groupProject: TGroupProjectServiceFactory;
- pkiAlert: TPkiAlertServiceFactory;
- project: TProjectServiceFactory;
- projectMembership: TProjectMembershipServiceFactory;
- projectEnv: TProjectEnvServiceFactory;
- projectKey: TProjectKeyServiceFactory;
- secret: TSecretServiceFactory;
- secretValueTracking: TSecretValueTrackingServiceFactory;
- secretReplication: TSecretReplicationServiceFactory;
- secretTag: TSecretTagServiceFactory;
- secretValidationRule: TSecretValidationRuleServiceFactory;
- secretImport: TSecretImportServiceFactory;
- resourceMetadata: TResourceMetadataServiceFactory;
- projectFolderGrant: TProjectFolderGrantServiceFactory;
- projectBot: TProjectBotServiceFactory;
- folder: TSecretFolderServiceFactory;
- integration: TIntegrationServiceFactory;
- integrationAuth: TIntegrationAuthServiceFactory;
- webhook: TWebhookServiceFactory;
- serviceToken: TServiceTokenServiceFactory;
- identityV1: TIdentityServiceFactory;
- identityV2: TScopedIdentityV2ServiceFactory;
- identityAccessToken: TIdentityAccessTokenServiceFactory;
- identityProject: TIdentityProjectServiceFactory;
- identityTokenAuth: TIdentityTokenAuthServiceFactory;
- identityUa: TIdentityUaServiceFactory;
- identityKubernetesAuth: TIdentityKubernetesAuthServiceFactory;
- identityGcpAuth: TIdentityGcpAuthServiceFactory;
- identityAliCloudAuth: TIdentityAliCloudAuthServiceFactory;
- identityTlsCertAuth: TIdentityTlsCertAuthServiceFactory;
- identityAwsAuth: TIdentityAwsAuthServiceFactory;
- identityAzureAuth: TIdentityAzureAuthServiceFactory;
- identityOciAuth: TIdentityOciAuthServiceFactory;
- identityOidcAuth: TIdentityOidcAuthServiceFactory;
- identityJwtAuth: TIdentityJwtAuthServiceFactory;
- identitySpiffeAuth: TIdentitySpiffeAuthServiceFactory;
- identityLdapAuth: TIdentityLdapAuthServiceFactory;
- accessApprovalPolicy: TAccessApprovalPolicyServiceFactory;
- secretAccessApprovalGlobalPolicyBridge: TSecretAccessApprovalGlobalPolicyBridgeServiceFactory;
- secretAccessApprovalGlobalRequestBridge: TSecretAccessApprovalGlobalRequestBridgeServiceFactory;
- accessApprovalRequest: TAccessApprovalRequestServiceFactory;
- secretApprovalPolicy: TSecretApprovalPolicyServiceFactory;
- secretChangeGlobalPolicyBridge: TSecretChangeGlobalPolicyBridgeServiceFactory;
- secretApprovalRequest: TSecretApprovalRequestServiceFactory;
- saml: TSamlConfigServiceFactory;
- scim: TScimServiceFactory;
- ldap: TLdapConfigServiceFactory;
- auditLog: TAuditLogServiceFactory;
- auditLogStream: TAuditLogStreamServiceFactory;
- auditLogSettings: TAuditLogSettingsServiceFactory;
- certificate: TCertificateServiceFactory;
- certificateCleanup: TCertificateCleanupServiceFactory;
- certificateInventoryView: TCertificateInventoryViewServiceFactory;
- certificateV3: TCertificateV3ServiceFactory;
- certificateRequest: TCertificateRequestServiceFactory;
- certificateTemplate: TCertificateTemplateServiceFactory;
- certificatePolicy: TCertificatePolicyServiceFactory;
- certificateProfile: TCertificateProfileServiceFactory;
- pkiApplication: TPkiApplicationServiceFactory;
- pkiApplicationMembership: TPkiApplicationMembershipServiceFactory;
- signerMembership: TSignerMembershipServiceFactory;
- signerPolicy: TSignerPolicyServiceFactory;
- pkiApplicationEnrollment: TPkiApplicationEnrollmentServiceFactory;
- certManagerProjectResolver: TCertManagerProjectResolverFactory;
- pamProjectResolver: TPamProjectResolverFactory;
- secretScanningV2Instance: TSecretScanningV2InstanceServiceFactory;
- secretScanningV2ProjectResolver: TSecretScanningV2ProjectResolverFactory;
- agentVaultProjectResolver: TAgentVaultProjectResolverFactory;
- agentVaultAccessBundle: TAgentVaultAccessBundleServiceFactory;
- agentVaultOauth: TAgentVaultOauthServiceFactory;
- agentVaultVariable: TAgentVaultVariableServiceFactory;
- agentVaultPersonalValue: TAgentVaultPersonalValueServiceFactory;
- agentVaultProxy: TAgentVaultProxyServiceFactory;
- agentVaultSession: TAgentVaultSessionServiceFactory;
- agentVaultSessionLog: TAgentVaultSessionLogServiceFactory;
- agentVaultMembership: TAgentVaultMembershipServiceFactory;
- certManagerInstance: TCertManagerInstanceServiceFactory;
- certManagerExport: TCertManagerExportServiceFactory;
- certificateAuthority: TCertificateAuthorityServiceFactory;
- certificateAuthorityCrl: TCertificateAuthorityCrlServiceFactory;
- certificateAuthorityOcsp: TCertificateAuthorityOcspServiceFactory;
- certificateEst: TCertificateEstServiceFactory;
- pkiAcme: TPkiAcmeServiceFactory;
- pkiScep: TPkiScepServiceFactory;
- certificateEstV3: TCertificateEstV3ServiceFactory;
- pkiCollection: TPkiCollectionServiceFactory;
- pkiSubscriber: TPkiSubscriberServiceFactory;
- pkiSync: TPkiSyncServiceFactory;
- pkiDiscovery: TPkiDiscoveryServiceFactory;
- pkiInstallation: TPkiInstallationServiceFactory;
- pkiSigner: TSignerServiceFactory;
- secretScanning: TSecretScanningServiceFactory;
- license: TLicenseServiceFactory;
- licenseClient: TLicenseClientFactory;
- licenseV2: TLicenseV2ServiceFactory;
- trustedIp: TTrustedIpServiceFactory;
- secretBlindIndex: TSecretBlindIndexServiceFactory;
- telemetry: TTelemetryServiceFactory;
- updateCheck: TUpdateCheckServiceFactory;
- dynamicSecret: TDynamicSecretServiceFactory;
- dynamicSecretLease: TDynamicSecretLeaseServiceFactory;
- emailDomain: TEmailDomainServiceFactory;
- secretSharing: TSecretSharingServiceFactory;
- userActivation: TUserActivationServiceFactory;
- userEngagement: TUserEngagementServiceFactory;
- externalKms: TExternalKmsServiceFactory;
- hsm: THsmServiceFactory;
- orgAdmin: TOrgAdminServiceFactory;
- slack: TSlackServiceFactory;
- workflowIntegration: TWorkflowIntegrationServiceFactory;
- cmek: TCmekServiceFactory;
- migration: TExternalMigrationServiceFactory;
- externalGroupOrgRoleMapping: TExternalGroupOrgRoleMappingServiceFactory;
- projectTemplate: TProjectTemplateServiceFactory;
- totp: TTotpServiceFactory;
- webAuthn: TWebAuthnServiceFactory;
- mfaRecoveryCode: TMfaRecoveryCodeServiceFactory;
- appConnection: TAppConnectionServiceFactory;
- hsmConnector: THsmConnectorServiceFactory;
- secretSync: TSecretSyncServiceFactory;
- kmip: TKmipServiceFactory;
- kmipOperation: TKmipOperationServiceFactory;
- kmipServer: TKmipServerServiceFactory;
- secretRotationV2: TSecretRotationV2ServiceFactory;
- microsoftTeams: TMicrosoftTeamsServiceFactory;
- assumePrivileges: TAssumePrivilegeServiceFactory;
- insights: TInsightsServiceFactory;
- secretReadActivity: TSecretReadActivityServiceFactory;
- auditReport: TAuditReportServiceFactory;
- relay: TRelayServiceFactory;
- gatewayV2: TGatewayV2ServiceFactory;
- gatewayPool: TGatewayPoolServiceFactory;
- resourceAuthMethod: TResourceAuthMethodServiceFactory;
- githubOrgSync: TGithubOrgSyncServiceFactory;
- gitHubApp: TGitHubAppServiceFactory;
- honeyTokenConfig: THoneyTokenConfigServiceFactory;
- honeyToken: THoneyTokenServiceFactory;
- proxiedService: TProxiedServiceServiceFactory;
- agentProxyCa: TAgentProxyCaServiceFactory;
- folderCommit: TFolderCommitServiceFactory;
- pit: TPitServiceFactory;
- secretScanningV2: TSecretScanningV2ServiceFactory;
- internalCertificateAuthority: TInternalCertificateAuthorityServiceFactory;
- pkiTemplate: TPkiTemplatesServiceFactory;
- reminder: TReminderServiceFactory;
- eventBus: TInternalEventBusService;
- projectEvents: TProjectEventsService;
- projectEventsSSE: TProjectEventsSSEService;
- identityAuthTemplate: TIdentityAuthTemplateServiceFactory;
- notification: TNotificationServiceFactory;
- alert: TAlertServiceFactory;
- alertChannelTest: TAlertChannelTestServiceFactory;
- announcement: TAnnouncementServiceFactory;
- offlineUsageReport: TOfflineUsageReportServiceFactory;
- orgProductStats: TOrgProductStatsServiceFactory;
- pamAccountTemplate: TPamAccountTemplateServiceFactory;
- pamFolder: TPamFolderServiceFactory;
- pamAccount: TPamAccountServiceFactory;
- pamDiscovery: TPamDiscoverySourceServiceFactory;
- pamAccountRotation: TPamAccountRotationServiceFactory;
- pamAccountHeartbeat: TPamAccountHeartbeatServiceFactory;
- pamMembership: TPamMembershipServiceFactory;
- pamSession: TPamSessionServiceFactory;
- pamSessionChunk: TPamSessionChunkServiceFactory;
- pamAccessRequest: TPamAccessRequestServiceFactory;
- pamWebAccess: TPamWebAccessServiceFactory;
- mfaSession: TMfaSessionServiceFactory;
- membershipUser: TMembershipUserServiceFactory;
- membershipIdentity: TMembershipIdentityServiceFactory;
- membershipGroup: TMembershipGroupServiceFactory;
- additionalPrivilege: TAdditionalPrivilegeServiceFactory;
- folderPermission: TFolderPermissionServiceFactory;
- role: TRoleServiceFactory;
- convertor: TConvertorServiceFactory;
- subOrganization: TSubOrgServiceFactory;
- pkiAlertV2: TPkiAlertV2ServiceFactory;
- approvalPolicy: TApprovalPolicyServiceFactory;
- appConnectionCredentialRotation: TAppConnectionCredentialRotationServiceFactory;
- caSigningConfig: TCaSigningConfigServiceFactory;
- caAutoRenewalQueue: TCaAutoRenewalQueueFactory;
- };
+ services: FastifyServices;
// this is exclusive use for middlewares in which we need to inject data
// everywhere else access using service layer
- store: {
- user: Pick<TUserDALFactory, "findById">;
- kmipClient: Pick<TKmipClientDALFactory, "findByProjectAndClientId">;
- };
+ store: FastifyStore;
+ }
+
+ // Kept as named interfaces, not inline object types: an inline type in the generic FastifyInstance is copied per
+ // instantiation, and comparing those copies resolves every service type on each route check (~3s per edit in the LSP).
+ interface FastifyServices {
+ login: TAuthLoginFactory;
+ password: TAuthPasswordFactory;
+ accountRecovery: TAccountRecoveryServiceFactory;
+ signup: TAuthSignupFactory;
+ authToken: TAuthTokenServiceFactory;
+ oauthClient: TOauthClientServiceFactory;
+ oidcIssuer: TOidcIssuerServiceFactory;
+ permission: TPermissionServiceFactory;
+ org: TOrgServiceFactory;
+ oidc: TOidcConfigServiceFactory;
+ superAdmin: TSuperAdminServiceFactory;
+ encryptionKeyRotation: TEncryptionKeyRotationServiceFactory;
+ user: TUserServiceFactory;
+ group: TGroupServiceFactory;
+ groupProject: TGroupProjectServiceFactory;
+ pkiAlert: TPkiAlertServiceFactory;
+ project: TProjectServiceFactory;
+ projectMembership: TProjectMembershipServiceFactory;
+ projectEnv: TProjectEnvServiceFactory;
+ projectKey: TProjectKeyServiceFactory;
+ secret: TSecretServiceFactory;
+ secretValueTracking: TSecretValueTrackingServiceFactory;
+ secretReplication: TSecretReplicationServiceFactory;
+ secretTag: TSecretTagServiceFactory;
+ secretValidationRule: TSecretValidationRuleServiceFactory;
+ secretImport: TSecretImportServiceFactory;
+ resourceMetadata: TResourceMetadataServiceFactory;
+ projectFolderGrant: TProjectFolderGrantServiceFactory;
+ projectBot: TProjectBotServiceFactory;
+ folder: TSecretFolderServiceFactory;
+ integration: TIntegrationServiceFactory;
+ integrationAuth: TIntegrationAuthServiceFactory;
+ webhook: TWebhookServiceFactory;
+ serviceToken: TServiceTokenServiceFactory;
+ identityV1: TIdentityServiceFactory;
+ identityV2: TScopedIdentityV2ServiceFactory;
+ identityAccessToken: TIdentityAccessTokenServiceFactory;
+ identityProject: TIdentityProjectServiceFactory;
+ identityTokenAuth: TIdentityTokenAuthServiceFactory;
+ identityUa: TIdentityUaServiceFactory;
+ identityKubernetesAuth: TIdentityKubernetesAuthServiceFactory;
+ identityGcpAuth: TIdentityGcpAuthServiceFactory;
+ identityAliCloudAuth: TIdentityAliCloudAuthServiceFactory;
+ identityTlsCertAuth: TIdentityTlsCertAuthServiceFactory;
+ identityAwsAuth: TIdentityAwsAuthServiceFactory;
+ identityAzureAuth: TIdentityAzureAuthServiceFactory;
+ identityOciAuth: TIdentityOciAuthServiceFactory;
+ identityOidcAuth: TIdentityOidcAuthServiceFactory;
+ identityJwtAuth: TIdentityJwtAuthServiceFactory;
+ identitySpiffeAuth: TIdentitySpiffeAuthServiceFactory;
+ identityLdapAuth: TIdentityLdapAuthServiceFactory;
+ accessApprovalPolicy: TAccessApprovalPolicyServiceFactory;
+ secretAccessApprovalGlobalPolicyBridge: TSecretAccessApprovalGlobalPolicyBridgeServiceFactory;
+ secretAccessApprovalGlobalRequestBridge: TSecretAccessApprovalGlobalRequestBridgeServiceFactory;
+ accessApprovalRequest: TAccessApprovalRequestServiceFactory;
+ secretApprovalPolicy: TSecretApprovalPolicyServiceFactory;
+ secretChangeGlobalPolicyBridge: TSecretChangeGlobalPolicyBridgeServiceFactory;
+ secretApprovalRequest: TSecretApprovalRequestServiceFactory;
+ saml: TSamlConfigServiceFactory;
+ scim: TScimServiceFactory;
+ ldap: TLdapConfigServiceFactory;
+ auditLog: TAuditLogServiceFactory;
+ auditLogStream: TAuditLogStreamServiceFactory;
+ auditLogSettings: TAuditLogSettingsServiceFactory;
+ certificate: TCertificateServiceFactory;
+ certificateCleanup: TCertificateCleanupServiceFactory;
+ certificateInventoryView: TCertificateInventoryViewServiceFactory;
+ certificateV3: TCertificateV3ServiceFactory;
+ certificateRequest: TCertificateRequestServiceFactory;
+ certificateTemplate: TCertificateTemplateServiceFactory;
+ certificatePolicy: TCertificatePolicyServiceFactory;
+ certificateProfile: TCertificateProfileServiceFactory;
+ pkiApplication: TPkiApplicationServiceFactory;
+ pkiApplicationMembership: TPkiApplicationMembershipServiceFactory;
+ signerMembership: TSignerMembershipServiceFactory;
+ signerPolicy: TSignerPolicyServiceFactory;
+ pkiApplicationEnrollment: TPkiApplicationEnrollmentServiceFactory;
+ certManagerProjectResolver: TCertManagerProjectResolverFactory;
+ pamProjectResolver: TPamProjectResolverFactory;
+ secretScanningV2Instance: TSecretScanningV2InstanceServiceFactory;
+ secretScanningV2ProjectResolver: TSecretScanningV2ProjectResolverFactory;
+ agentVaultProjectResolver: TAgentVaultProjectResolverFactory;
+ agentVaultAccessBundle: TAgentVaultAccessBundleServiceFactory;
+ agentVaultOauth: TAgentVaultOauthServiceFactory;
+ agentVaultVariable: TAgentVaultVariableServiceFactory;
+ agentVaultPersonalValue: TAgentVaultPersonalValueServiceFactory;
+ agentVaultProxy: TAgentVaultProxyServiceFactory;
+ agentVaultSession: TAgentVaultSessionServiceFactory;
+ agentVaultSessionLog: TAgentVaultSessionLogServiceFactory;
+ agentVaultMembership: TAgentVaultMembershipServiceFactory;
+ certManagerInstance: TCertManagerInstanceServiceFactory;
+ certManagerExport: TCertManagerExportServiceFactory;
+ certificateAuthority: TCertificateAuthorityServiceFactory;
+ certificateAuthorityCrl: TCertificateAuthorityCrlServiceFactory;
+ certificateAuthorityOcsp: TCertificateAuthorityOcspServiceFactory;
+ certificateEst: TCertificateEstServiceFactory;
+ pkiAcme: TPkiAcmeServiceFactory;
+ pkiScep: TPkiScepServiceFactory;
+ certificateEstV3: TCertificateEstV3ServiceFactory;
+ pkiCollection: TPkiCollectionServiceFactory;
+ pkiSubscriber: TPkiSubscriberServiceFactory;
+ pkiSync: TPkiSyncServiceFactory;
+ pkiDiscovery: TPkiDiscoveryServiceFactory;
+ pkiInstallation: TPkiInstallationServiceFactory;
+ pkiSigner: TSignerServiceFactory;
+ secretScanning: TSecretScanningServiceFactory;
+ license: TLicenseServiceFactory;
+ licenseClient: TLicenseClientFactory;
+ licenseV2: TLicenseV2ServiceFactory;
+ trustedIp: TTrustedIpServiceFactory;
+ secretBlindIndex: TSecretBlindIndexServiceFactory;
+ telemetry: TTelemetryServiceFactory;
+ updateCheck: TUpdateCheckServiceFactory;
+ dynamicSecret: TDynamicSecretServiceFactory;
+ dynamicSecretLease: TDynamicSecretLeaseServiceFactory;
+ emailDomain: TEmailDomainServiceFactory;
+ secretSharing: TSecretSharingServiceFactory;
+ userActivation: TUserActivationServiceFactory;
+ userEngagement: TUserEngagementServiceFactory;
+ externalKms: TExternalKmsServiceFactory;
+ hsm: THsmServiceFactory;
+ orgAdmin: TOrgAdminServiceFactory;
+ slack: TSlackServiceFactory;
+ workflowIntegration: TWorkflowIntegrationServiceFactory;
+ cmek: TCmekServiceFactory;
+ migration: TExternalMigrationServiceFactory;
+ externalGroupOrgRoleMapping: TExternalGroupOrgRoleMappingServiceFactory;
+ projectTemplate: TProjectTemplateServiceFactory;
+ totp: TTotpServiceFactory;
+ webAuthn: TWebAuthnServiceFactory;
+ mfaRecoveryCode: TMfaRecoveryCodeServiceFactory;
+ appConnection: TAppConnectionServiceFactory;
+ hsmConnector: THsmConnectorServiceFactory;
+ secretSync: TSecretSyncServiceFactory;
+ kmip: TKmipServiceFactory;
+ kmipOperation: TKmipOperationServiceFactory;
+ kmipServer: TKmipServerServiceFactory;
+ secretRotationV2: TSecretRotationV2ServiceFactory;
+ microsoftTeams: TMicrosoftTeamsServiceFactory;
+ assumePrivileges: TAssumePrivilegeServiceFactory;
+ insights: TInsightsServiceFactory;
++ secretReadActivity: TSecretReadActivityServiceFactory;
+ auditReport: TAuditReportServiceFactory;
+ relay: TRelayServiceFactory;
+ gatewayV2: TGatewayV2ServiceFactory;
+ gatewayPool: TGatewayPoolServiceFactory;
+ resourceAuthMethod: TResourceAuthMethodServiceFactory;
+ githubOrgSync: TGithubOrgSyncServiceFactory;
+ gitHubApp: TGitHubAppServiceFactory;
+ honeyTokenConfig: THoneyTokenConfigServiceFactory;
+ honeyToken: THoneyTokenServiceFactory;
+ proxiedService: TProxiedServiceServiceFactory;
+ agentProxyCa: TAgentProxyCaServiceFactory;
+ folderCommit: TFolderCommitServiceFactory;
+ pit: TPitServiceFactory;
+ secretScanningV2: TSecretScanningV2ServiceFactory;
+ internalCertificateAuthority: TInternalCertificateAuthorityServiceFactory;
+ pkiTemplate: TPkiTemplatesServiceFactory;
+ reminder: TReminderServiceFactory;
+ eventBus: TInternalEventBusService;
+ projectEvents: TProjectEventsService;
+ projectEventsSSE: TProjectEventsSSEService;
+ identityAuthTemplate: TIdentityAuthTemplateServiceFactory;
+ notification: TNotificationServiceFactory;
+ alert: TAlertServiceFactory;
+ alertChannelTest: TAlertChannelTestServiceFactory;
+ announcement: TAnnouncementServiceFactory;
+ offlineUsageReport: TOfflineUsageReportServiceFactory;
+ orgProductStats: TOrgProductStatsServiceFactory;
+ pamAccountTemplate: TPamAccountTemplateServiceFactory;
+ pamFolder: TPamFolderServiceFactory;
+ pamAccount: TPamAccountServiceFactory;
+ pamDiscovery: TPamDiscoverySourceServiceFactory;
+ pamAccountRotation: TPamAccountRotationServiceFactory;
+ pamAccountHeartbeat: TPamAccountHeartbeatServiceFactory;
+ pamMembership: TPamMembershipServiceFactory;
+ pamSession: TPamSessionServiceFactory;
+ pamSessionChunk: TPamSessionChunkServiceFactory;
+ pamAccessRequest: TPamAccessRequestServiceFactory;
+ pamWebAccess: TPamWebAccessServiceFactory;
+ mfaSession: TMfaSessionServiceFactory;
+ membershipUser: TMembershipUserServiceFactory;
+ membershipIdentity: TMembershipIdentityServiceFactory;
+ membershipGroup: TMembershipGroupServiceFactory;
+ additionalPrivilege: TAdditionalPrivilegeServiceFactory;
+ folderPermission: TFolderPermissionServiceFactory;
+ role: TRoleServiceFactory;
+ convertor: TConvertorServiceFactory;
+ subOrganization: TSubOrgServiceFactory;
+ pkiAlertV2: TPkiAlertV2ServiceFactory;
+ approvalPolicy: TApprovalPolicyServiceFactory;
+ delegatedApproval: TDelegatedApprovalServiceFactory;
+ delegatedApprovalCallback: TDelegatedApprovalCallbackServiceFactory;
+ appConnectionCredentialRotation: TAppConnectionCredentialRotationServiceFactory;
+ caSigningConfig: TCaSigningConfigServiceFactory;
+ caAutoRenewalQueue: TCaAutoRenewalQueueFactory;
+ }
+
+ interface FastifyStore {
+ user: Pick<TUserDALFactory, "findById">;
+ kmipClient: Pick<TKmipClientDALFactory, "findByProjectAndClientId">;
}
}