Skip to content

Commit 0a74132

Browse files
committed
fix: enforce org-scoped access and tighten ACLs
- Require organization-scoped checks for Git provider routes - Align router and service validation to prevent cross-org access - add missing drizzle snapshot and journal
1 parent 7f617e2 commit 0a74132

File tree

2 files changed

+41
-12
lines changed

2 files changed

+41
-12
lines changed

apps/dokploy/server/api/routers/application.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
addNewService,
3+
canAccessProvider,
34
checkServiceAccess,
45
createApplication,
56
deleteAllMiddlewares,
@@ -403,8 +404,11 @@ export const applicationRouter = createTRPCRouter({
403404
.mutation(async ({ input, ctx }) => {
404405
const application = await findApplicationById(input.applicationId);
405406
if (
406-
application.environment.project.organizationId !==
407-
ctx.session.activeOrganizationId
407+
!canAccessProvider(
408+
application.github?.gitProvider!,
409+
ctx.session.activeOrganizationId,
410+
ctx.session.userId,
411+
)
408412
) {
409413
throw new TRPCError({
410414
code: "UNAUTHORIZED",
@@ -431,8 +435,11 @@ export const applicationRouter = createTRPCRouter({
431435
.mutation(async ({ input, ctx }) => {
432436
const application = await findApplicationById(input.applicationId);
433437
if (
434-
application.environment.project.organizationId !==
435-
ctx.session.activeOrganizationId
438+
!canAccessProvider(
439+
application.gitlab?.gitProvider!,
440+
ctx.session.activeOrganizationId,
441+
ctx.session.userId,
442+
)
436443
) {
437444
throw new TRPCError({
438445
code: "UNAUTHORIZED",
@@ -460,8 +467,11 @@ export const applicationRouter = createTRPCRouter({
460467
.mutation(async ({ input, ctx }) => {
461468
const application = await findApplicationById(input.applicationId);
462469
if (
463-
application.environment.project.organizationId !==
464-
ctx.session.activeOrganizationId
470+
!canAccessProvider(
471+
application.bitbucket?.gitProvider!,
472+
ctx.session.activeOrganizationId,
473+
ctx.session.userId,
474+
)
465475
) {
466476
throw new TRPCError({
467477
code: "UNAUTHORIZED",
@@ -487,8 +497,11 @@ export const applicationRouter = createTRPCRouter({
487497
.mutation(async ({ input, ctx }) => {
488498
const application = await findApplicationById(input.applicationId);
489499
if (
490-
application.environment.project.organizationId !==
491-
ctx.session.activeOrganizationId
500+
!canAccessProvider(
501+
application.gitea?.gitProvider!,
502+
ctx.session.activeOrganizationId,
503+
ctx.session.userId,
504+
)
492505
) {
493506
throw new TRPCError({
494507
code: "UNAUTHORIZED",

packages/server/src/services/application.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,26 @@ export const findApplicationById = async (applicationId: string) => {
105105
security: true,
106106
ports: true,
107107
registry: true,
108-
gitlab: true,
109-
github: true,
110-
bitbucket: true,
111-
gitea: true,
108+
gitlab: {
109+
with: {
110+
gitProvider: true,
111+
},
112+
},
113+
github: {
114+
with: {
115+
gitProvider: true,
116+
},
117+
},
118+
bitbucket: {
119+
with: {
120+
gitProvider: true,
121+
},
122+
},
123+
gitea: {
124+
with: {
125+
gitProvider: true,
126+
},
127+
},
112128
server: true,
113129
previewDeployments: true,
114130
buildRegistry: true,

0 commit comments

Comments
 (0)