mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-09 22:28:25 +00:00
Address PR comments
This commit is contained in:
@@ -560,24 +560,14 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
let { workspaceId } = req.body;
|
let { workspaceId } = req.body;
|
||||||
if (req.permission.type === ActorType.IDENTITY && req.body.projectSlug && !workspaceId) {
|
workspaceId = await server.services.project.extractProjectIdFromSlug({
|
||||||
const workspace = await server.services.project.getAProject({
|
projectSlug: req.body.projectSlug,
|
||||||
filter: {
|
projectId: req.body.workspaceId,
|
||||||
type: ProjectFilterType.SLUG,
|
actorId: req.permission.id,
|
||||||
orgId: req.permission.orgId,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
slug: req.body.projectSlug
|
actor: req.permission.type,
|
||||||
},
|
actorOrgId: req.permission.orgId
|
||||||
actorId: req.permission.id,
|
});
|
||||||
actorAuthMethod: req.permission.authMethod,
|
|
||||||
actor: req.permission.type,
|
|
||||||
actorOrgId: req.permission.orgId
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!workspace) throw new NotFoundError({ message: `No project found with slug ${req.body.projectSlug}` });
|
|
||||||
|
|
||||||
workspaceId = workspace.id;
|
|
||||||
}
|
|
||||||
if (!workspaceId) throw new BadRequestError({ message: "You must provide workspaceId or projectSlug" });
|
|
||||||
|
|
||||||
const secretOperation = await server.services.secret.createSecretRaw({
|
const secretOperation = await server.services.secret.createSecretRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
@@ -702,24 +692,14 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
let { workspaceId } = req.body;
|
let { workspaceId } = req.body;
|
||||||
if (req.permission.type === ActorType.IDENTITY && req.body.projectSlug && !workspaceId) {
|
workspaceId = await server.services.project.extractProjectIdFromSlug({
|
||||||
const workspace = await server.services.project.getAProject({
|
projectSlug: req.body.projectSlug,
|
||||||
filter: {
|
projectId: req.body.workspaceId,
|
||||||
type: ProjectFilterType.SLUG,
|
actorId: req.permission.id,
|
||||||
orgId: req.permission.orgId,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
slug: req.body.projectSlug
|
actor: req.permission.type,
|
||||||
},
|
actorOrgId: req.permission.orgId
|
||||||
actorId: req.permission.id,
|
});
|
||||||
actorAuthMethod: req.permission.authMethod,
|
|
||||||
actor: req.permission.type,
|
|
||||||
actorOrgId: req.permission.orgId
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!workspace) throw new NotFoundError({ message: `No project found with slug ${req.body.projectSlug}` });
|
|
||||||
|
|
||||||
workspaceId = workspace.id;
|
|
||||||
}
|
|
||||||
if (!workspaceId) throw new BadRequestError({ message: "You must provide workspaceId or projectSlug" });
|
|
||||||
|
|
||||||
const secretOperation = await server.services.secret.updateSecretRaw({
|
const secretOperation = await server.services.secret.updateSecretRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
@@ -824,24 +804,14 @@ export const registerSecretRouter = async (server: FastifyZodProvider) => {
|
|||||||
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
onRequest: verifyAuth([AuthMode.JWT, AuthMode.API_KEY, AuthMode.SERVICE_TOKEN, AuthMode.IDENTITY_ACCESS_TOKEN]),
|
||||||
handler: async (req) => {
|
handler: async (req) => {
|
||||||
let { workspaceId } = req.body;
|
let { workspaceId } = req.body;
|
||||||
if (req.permission.type === ActorType.IDENTITY && req.body.projectSlug && !workspaceId) {
|
workspaceId = await server.services.project.extractProjectIdFromSlug({
|
||||||
const workspace = await server.services.project.getAProject({
|
projectSlug: req.body.projectSlug,
|
||||||
filter: {
|
projectId: req.body.workspaceId,
|
||||||
type: ProjectFilterType.SLUG,
|
actorId: req.permission.id,
|
||||||
orgId: req.permission.orgId,
|
actorAuthMethod: req.permission.authMethod,
|
||||||
slug: req.body.projectSlug
|
actor: req.permission.type,
|
||||||
},
|
actorOrgId: req.permission.orgId
|
||||||
actorId: req.permission.id,
|
});
|
||||||
actorAuthMethod: req.permission.authMethod,
|
|
||||||
actor: req.permission.type,
|
|
||||||
actorOrgId: req.permission.orgId
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!workspace) throw new NotFoundError({ message: `No project found with slug ${req.body.projectSlug}` });
|
|
||||||
|
|
||||||
workspaceId = workspace.id;
|
|
||||||
}
|
|
||||||
if (!workspaceId) throw new BadRequestError({ message: "You must provide workspaceId or projectSlug" });
|
|
||||||
|
|
||||||
const secretOperation = await server.services.secret.deleteSecretRaw({
|
const secretOperation = await server.services.secret.deleteSecretRaw({
|
||||||
actorId: req.permission.id,
|
actorId: req.permission.id,
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import { TProjectPermission } from "@app/lib/types";
|
|||||||
import { TQueueServiceFactory } from "@app/queue";
|
import { TQueueServiceFactory } from "@app/queue";
|
||||||
import { TPkiSubscriberDALFactory } from "@app/services/pki-subscriber/pki-subscriber-dal";
|
import { TPkiSubscriberDALFactory } from "@app/services/pki-subscriber/pki-subscriber-dal";
|
||||||
|
|
||||||
import { ActorType } from "../auth/auth-type";
|
import { ActorAuthMethod, ActorType } from "../auth/auth-type";
|
||||||
import { TCertificateDALFactory } from "../certificate/certificate-dal";
|
import { TCertificateDALFactory } from "../certificate/certificate-dal";
|
||||||
import { TCertificateAuthorityDALFactory } from "../certificate-authority/certificate-authority-dal";
|
import { TCertificateAuthorityDALFactory } from "../certificate-authority/certificate-authority-dal";
|
||||||
import { expandInternalCa } from "../certificate-authority/certificate-authority-fns";
|
import { expandInternalCa } from "../certificate-authority/certificate-authority-fns";
|
||||||
@@ -82,6 +82,7 @@ import { assignWorkspaceKeysToMembers, bootstrapSshProject, createProjectKey } f
|
|||||||
import { TProjectQueueFactory } from "./project-queue";
|
import { TProjectQueueFactory } from "./project-queue";
|
||||||
import { TProjectSshConfigDALFactory } from "./project-ssh-config-dal";
|
import { TProjectSshConfigDALFactory } from "./project-ssh-config-dal";
|
||||||
import {
|
import {
|
||||||
|
ProjectFilterType,
|
||||||
TCreateProjectDTO,
|
TCreateProjectDTO,
|
||||||
TDeleteProjectDTO,
|
TDeleteProjectDTO,
|
||||||
TDeleteProjectWorkflowIntegration,
|
TDeleteProjectWorkflowIntegration,
|
||||||
@@ -866,6 +867,39 @@ export const projectServiceFactory = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const extractProjectIdFromSlug = async ({
|
||||||
|
projectSlug,
|
||||||
|
projectId,
|
||||||
|
actorId,
|
||||||
|
actorAuthMethod,
|
||||||
|
actor,
|
||||||
|
actorOrgId
|
||||||
|
}: {
|
||||||
|
projectSlug?: string;
|
||||||
|
projectId?: string;
|
||||||
|
actorId: string;
|
||||||
|
actorAuthMethod: ActorAuthMethod;
|
||||||
|
actor: ActorType;
|
||||||
|
actorOrgId: string;
|
||||||
|
}) => {
|
||||||
|
if (projectId) return projectId;
|
||||||
|
if (!projectSlug) throw new BadRequestError({ message: "You must provide projectSlug or workspaceId" });
|
||||||
|
const project = await getAProject({
|
||||||
|
filter: {
|
||||||
|
type: ProjectFilterType.SLUG,
|
||||||
|
orgId: actorOrgId,
|
||||||
|
slug: projectSlug
|
||||||
|
},
|
||||||
|
actorId,
|
||||||
|
actorAuthMethod,
|
||||||
|
actor,
|
||||||
|
actorOrgId
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!project) throw new NotFoundError({ message: `No project found with slug ${projectSlug}` });
|
||||||
|
return project.id;
|
||||||
|
};
|
||||||
|
|
||||||
const getProjectUpgradeStatus = async ({
|
const getProjectUpgradeStatus = async ({
|
||||||
projectId,
|
projectId,
|
||||||
actor,
|
actor,
|
||||||
@@ -2006,6 +2040,7 @@ export const projectServiceFactory = ({
|
|||||||
getProjectSshConfig,
|
getProjectSshConfig,
|
||||||
updateProjectSshConfig,
|
updateProjectSshConfig,
|
||||||
requestProjectAccess,
|
requestProjectAccess,
|
||||||
searchProjects
|
searchProjects,
|
||||||
|
extractProjectIdFromSlug
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user