fix: correct permission checks for compose loadServices and env editing#4164
Merged
Siumauricio merged 1 commit intocanaryfrom Apr 5, 2026
Merged
Conversation
- 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
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #4052
compose.loadServicesrequiredservice: ["create"]but it's a read-only operation (parses YAML and returns service names). Changed toservice: ["read"].updatemutation which requiresservice: ["create"]. All database routers already hadsaveEnvironmentendpoints with correctenvVars: ["write"]permission, but compose was missing one. Addedcompose.saveEnvironmentand updated the frontend to usesaveEnvironmentfor all service types.Changes
packages/server/src/db/schema/compose.ts— AddedapiSaveEnvironmentVariablesComposeinput schemaapps/dokploy/server/api/routers/compose.ts— ChangedloadServicespermission toservice: ["read"], addedsaveEnvironmentendpoint withenvVars: ["write"]apps/dokploy/components/dashboard/application/environment/show-environment.tsx— Updated all mutation calls from.updateto.saveEnvironmentTest plan
updatemutationGreptile 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.loadServiceshadservice: ["create"]permission but is a purely read-only operation (parses YAML and returns service names). Correctly changed toservice: ["read"].compose.saveEnvironmentis a new endpoint added withenvVars: ["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.updatemutation which incorrectly requiredservice: ["create"]permission.show-environment.tsxis updated to call.saveEnvironment(instead of.update) for all 7 service types in the mutation map, so members withenvVars.writebut withoutservice.createcan now save environment variables on any service type.apiSaveEnvironmentVariablesComposeschema incompose.tsis minimal and follows the exact same pattern asapiSaveEnvironmentVariablesMongoand its siblings.saveEnvironmentendpoint correctly fires an audit event and throws aBAD_REQUESTerror if the update returns nothing, consistent with all other servicesaveEnvironmentimplementations.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
saveEnvironmentendpoint mirrors every other service's implementation exactly. TheloadServicespermission 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