Skip to content

fix: correct permission checks for compose loadServices and env editing#4164

Merged
Siumauricio merged 1 commit intocanaryfrom
fix/permission-checks-env-and-load-services
Apr 5, 2026
Merged

fix: correct permission checks for compose loadServices and env editing#4164
Siumauricio merged 1 commit intocanaryfrom
fix/permission-checks-env-and-load-services

Conversation

@Siumauricio
Copy link
Copy Markdown
Contributor

@Siumauricio Siumauricio commented Apr 5, 2026

Summary

Fixes #4052

  • compose.loadServices required service: ["create"] but it's a read-only operation (parses YAML and returns service names). Changed to service: ["read"].
  • Environment editing on database/compose services used the generic update mutation which requires service: ["create"]. All database routers already had saveEnvironment endpoints with correct envVars: ["write"] permission, but compose was missing one. Added compose.saveEnvironment and updated the frontend to use saveEnvironment for all service types.

Changes

  1. packages/server/src/db/schema/compose.ts — Added apiSaveEnvironmentVariablesCompose input schema
  2. apps/dokploy/server/api/routers/compose.ts — Changed loadServices permission to service: ["read"], added saveEnvironment endpoint with envVars: ["write"]
  3. apps/dokploy/components/dashboard/application/environment/show-environment.tsx — Updated all mutation calls from .update to .saveEnvironment

Test plan

  • Create a member user without "Create Services" permission but with project access
  • Verify the member can load compose service names in the domain form dropdown
  • Verify the member can edit and save environment variables on compose services
  • Verify the member can edit and save environment variables on database services (postgres, mysql, mariadb, redis, mongo)
  • Verify that users with full permissions can still update services normally via the update mutation

Greptile Summary

This PR fixes two permission check bugs for compose services and refactors environment variable saving to use purpose-specific endpoints across all service types.

  • compose.loadServices had service: ["create"] permission but is a purely read-only operation (parses YAML and returns service names). Correctly changed to service: ["read"].
  • compose.saveEnvironment is a new endpoint added with envVars: ["write"] permission, following the exact same pattern already established for all other service types (mongo, postgres, redis, etc.). Previously, compose was the only service type missing this endpoint, meaning environment variable saves for compose went through the generic .update mutation which incorrectly required service: ["create"] permission.
  • show-environment.tsx is updated to call .saveEnvironment (instead of .update) for all 7 service types in the mutation map, so members with envVars.write but without service.create can now save environment variables on any service type.
  • The new apiSaveEnvironmentVariablesCompose schema in compose.ts is minimal and follows the exact same pattern as apiSaveEnvironmentVariablesMongo and its siblings.
  • The saveEnvironment endpoint correctly fires an audit event and throws a BAD_REQUEST error if the update returns nothing, consistent with all other service saveEnvironment implementations.

Confidence Score: 5/5

Safe to merge — focused permission fix with no behavioural regressions for existing users.

All three changes are minimal, correct, and consistent with established patterns in the codebase. The new saveEnvironment endpoint mirrors every other service's implementation exactly. The loadServices permission change is semantically correct (read-only operation now requires read permission). No logic errors, security regressions, or unhandled edge cases were found.

No files require special attention.

Reviews (1): Last reviewed commit: "fix: correct permission checks for compo..." | Re-trigger Greptile

- Change compose.loadServices permission from service:create to service:read
  since loading services from a compose file is a read-only operation
- Add saveEnvironment endpoint to compose router with envVars:write permission
- Update show-environment.tsx to use saveEnvironment mutations instead of
  generic update mutations for all service types (compose, databases)

Closes #4052
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Apr 5, 2026
@Siumauricio Siumauricio merged commit 30d5493 into canary Apr 5, 2026
5 checks passed
@Siumauricio Siumauricio deleted the fix/permission-checks-env-and-load-services branch April 5, 2026 19:59
iRazvan2745 pushed a commit to iRazvan2745/forkploy that referenced this pull request Apr 10, 2026
…v-and-load-services

fix: correct permission checks for compose loadServices and env editing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Create Services" permission incorrectly required for domain service selection and environment editing

1 participant