[Fix-18283][API] Add project permission check on workflow lineage and workflow-definition list endpoints#18284
Open
ruanwenjun wants to merge 1 commit into
Open
[Fix-18283][API] Add project permission check on workflow lineage and workflow-definition list endpoints#18284ruanwenjun wants to merge 1 commit into
ruanwenjun wants to merge 1 commit into
Conversation
… workflow-definition list endpoints The five `WorkflowLineageController` endpoints and two `WorkflowDefinitionController` list endpoints accept a `projectCode` parameter but did not verify whether the login user has access to that project. Any logged-in user could read project-scoped metadata for projects they have no permission to. Route every affected service method through `ProjectService.checkProjectAndAuthThrowException` with the existing `WORKFLOW_DEFINITION` permission, mirroring the pattern used by sibling endpoints (e.g. `/workflow-definition/all`, `/workflow-instances`). - WorkflowLineageService: add `User loginUser` to the 5 endpoint-facing methods; service impl now calls `checkProjectAndAuthThrowException` after looking up the project, including `taskDependentMsg` which previously did not even verify project existence. - WorkflowDefinitionService: add `User loginUser` to `queryWorkflowDefinitionListByProjectCode` and `queryTaskDefinitionListByWorkflowDefinitionCode`; both impls now verify access. - WorkflowDefinitionServiceImpl: propagate `loginUser` through `taskUsedInOtherTaskValid` and `workflowDefinitionUsedInOtherTaskValid` so the inner `taskDependentMsg` calls compile against the new signature. - Controllers: thread `loginUser` into the seven endpoints' service calls. - Tests: adapt existing mocks to the new signatures; add a negative test that confirms `queryWorkFlowLineageByName` rejects an unauthorized user with `USER_NO_OPERATION_PROJECT_PERM`.
|
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.


Was this PR generated or assisted by AI?
YES. Drafted with the help of Claude Code: it scanned the API module, identified the seven controller endpoints that accepted a
projectCodeparameter without going throughProjectService.checkProjectAndAuthThrowException, applied the fix, and adapted the affected tests. Every change was reviewed and validated locally before commit.Purpose of the pull request
Closes #18283.
Seven REST endpoints in the API server accept a
projectCodepath/query parameter but do not check whether the login user actually has access to that project. As a result any logged-in user can read project-scoped metadata for projects they have no permission to.Affected endpoints (none of them previously called
ProjectService.checkProjectAndAuthThrowException):WorkflowLineageControllerGET /projects/{projectCode}/lineages/query-by-nameGET /projects/{projectCode}/lineages/{workFlowCode}GET /projects/{projectCode}/lineages/listPOST /projects/{projectCode}/lineages/tasks/verify-delete(this one did not even verify project existence)GET /projects/{projectCode}/lineages/query-dependent-tasksWorkflowDefinitionControllerGET /projects/{projectCode}/workflow-definition/query-workflow-definition-listGET /projects/{projectCode}/workflow-definition/query-task-definition-listBrief change log
WorkflowLineageService: addUser loginUserto the 5 endpoint-facing methods.WorkflowLineageServiceImpl: every public method now callsProjectService.checkProjectAndAuthThrowException(loginUser, project, WORKFLOW_DEFINITION)after looking up the project;taskDependentMsgadditionally now verifies project existence.WorkflowDefinitionService: addUser loginUsertoqueryWorkflowDefinitionListByProjectCodeandqueryTaskDefinitionListByWorkflowDefinitionCode.WorkflowDefinitionServiceImpl: both list methods now check user access;taskUsedInOtherTaskValidandworkflowDefinitionUsedInOtherTaskValidthreadloginUserthrough to the innertaskDependentMsgcalls.loginUserinto the seven endpoints' service calls.testQueryWorkFlowLineageByNameWithoutProjectPerm) confirming an unauthorized user getsUSER_NO_OPERATION_PROJECT_PERM.Verify this pull request
This change added tests and can be verified as follows:
WorkflowTaskLineageServiceTest,WorkflowLineageServiceImplTest,WorkflowTaskLineageControllerTest,WorkflowDefinitionServiceTest, andWorkflowDefinitionControllerTestwere updated to passloginUserand continue to pass.WorkflowTaskLineageServiceTest#testQueryWorkFlowLineageByNameWithoutProjectPerm, mocksProjectServiceto throwUSER_NO_OPERATION_PROJECT_PERMand asserts the service propagates it and never calls the underlying DAO../mvnw verify -pl dolphinscheduler-api -Dspotless.skip=true -DskipUT=falsereportsTests run: 687, Failures: 0, Errors: 0(skipped 12, all pre-existing)../mvnw spotless:check -pl dolphinscheduler-apiis clean.Pull Request Notice
Pull Request Notice
This change is not a wire/DB/SPI break: only Java internal method signatures change. UI clients continue to call the same HTTP endpoints, but unauthorized callers now receive
USER_NO_OPERATION_PROJECT_PERMinstead of getting back unrelated project data. No update todocs/docs/en/guide/upgrade/incompatible.mdis needed.