Skip to content

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

Feat: List secrets by project slug

Daniel Hougaardc0b0c0754b99
diff --git a/backend/src/server/routes/v3/secret-router.ts b/backend/src/server/routes/v3/secret-router.ts
index 65219d0ab9..23d5496d0b 100644
--- a/backend/src/server/routes/v3/secret-router.ts
+++ b/backend/src/server/routes/v3/secret-router.ts
@@ -17,6 +17,7 @@ import { getTelemetryDistinctId } from "@app/server/lib/telemetry";
import { getUserAgentType } from "@app/server/plugins/audit-log";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
import { ActorType, AuthMode } from "@app/services/auth/auth-type";
+import { ProjectFilterType } from "@app/services/project/project-types";
import { PostHogEventTypes } from "@app/services/telemetry/telemetry-types";
import { secretRawSchema } from "../sanitizedSchemas";
@@ -70,6 +71,18 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
environment = scope[0].environment;
workspaceId = req.auth.serviceToken.projectId;
}
+ } else if (req.permission.type === ActorType.IDENTITY && req.query.workspaceSlug && !workspaceId) {
+ const workspace = await server.services.project.getAProject({
+ filter: {
+ type: ProjectFilterType.SLUG,
+ orgId: req.permission.orgId,
+ slug: req.query.workspaceSlug
+ },
+ actorId: req.permission.id,
+ actor: req.permission.type,
+ actorOrgId: req.permission.orgId
+ });
+ workspaceId = workspace.id;
}
if (!workspaceId || !environment) throw new BadRequestError({ message: "Missing workspace id or environment" });
@@ -85,7 +98,7 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
});
await server.services.auditLog.createAuditLog({
- projectId: req.query.workspaceId,
+ projectId: workspaceId,
...req.auditLogInfo,
event: {
type: EventType.GET_SECRETS,