mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
feat(deployment): add server access validation for deployment actions
- Implemented server access validation in deployment procedures to ensure users can only access deployments associated with their active organization. - Added checks to throw an UNAUTHORIZED error if a user attempts to access a deployment linked to a server outside their organization. This enhancement improves security and access control within the deployment management system.
This commit is contained in:
@@ -151,6 +151,14 @@ export const deploymentRouter = createTRPCRouter({
|
||||
await checkServicePermissionAndAccess(ctx, serviceId, {
|
||||
deployment: ["cancel"],
|
||||
});
|
||||
} else if (deployment.schedule?.serverId) {
|
||||
const targetServer = await findServerById(deployment.schedule.serverId);
|
||||
if (targetServer.organizationId !== ctx.session.activeOrganizationId) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "You don't have access to this deployment.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!deployment.pid) {
|
||||
@@ -188,6 +196,14 @@ export const deploymentRouter = createTRPCRouter({
|
||||
await checkServicePermissionAndAccess(ctx, serviceId, {
|
||||
deployment: ["cancel"],
|
||||
});
|
||||
} else if (deployment.schedule?.serverId) {
|
||||
const targetServer = await findServerById(deployment.schedule.serverId);
|
||||
if (targetServer.organizationId !== ctx.session.activeOrganizationId) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "You don't have access to this deployment.",
|
||||
});
|
||||
}
|
||||
}
|
||||
const result = await removeDeployment(input.deploymentId);
|
||||
await audit(ctx, {
|
||||
@@ -212,6 +228,14 @@ export const deploymentRouter = createTRPCRouter({
|
||||
await checkServicePermissionAndAccess(ctx, serviceId, {
|
||||
deployment: ["read"],
|
||||
});
|
||||
} else if (deployment.schedule?.serverId) {
|
||||
const targetServer = await findServerById(deployment.schedule.serverId);
|
||||
if (targetServer.organizationId !== ctx.session.activeOrganizationId) {
|
||||
throw new TRPCError({
|
||||
code: "UNAUTHORIZED",
|
||||
message: "You don't have access to this deployment.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (!deployment.logPath) {
|
||||
|
||||
Reference in New Issue
Block a user