Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Added authorization for workflow operations
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindanr committed Oct 13, 2022
1 parent 0787f84 commit a63c37a
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;

import com.netflix.conductor.annotations.Trace;
Expand Down Expand Up @@ -153,6 +154,7 @@ public void resetCallbacksForWorkflow(String workflowId) {
});
}

@PreAuthorize("hasPermission(#request, 'OPERATOR')")
public String rerun(RerunWorkflowRequest request) {
Utils.checkNotNull(request.getReRunFromWorkflowId(), "reRunFromWorkflowId is missing");
if (!rerunWF(
Expand All @@ -175,6 +177,7 @@ public String rerun(RerunWorkflowRequest request) {
* @throws NotFoundException Workflow definition is not found or Workflow is deemed
* non-restartable as per workflow definition.
*/
@PreAuthorize("hasPermission(#workflowId, 'OPERATOR')")
public void restart(String workflowId, boolean useLatestDefinitions) {
final WorkflowModel workflow = executionDAOFacade.getWorkflowModel(workflowId, true);

Expand Down Expand Up @@ -260,6 +263,7 @@ public void restart(String workflowId, boolean useLatestDefinitions) {
*
* @param workflowId the id of the workflow to be retried
*/
@PreAuthorize("hasPermission(#workflowId, 'OPERATOR')")
public void retry(String workflowId, boolean resumeSubworkflowTasks) {
WorkflowModel workflow = executionDAOFacade.getWorkflowModel(workflowId, true);
if (!workflow.getStatus().isTerminal()) {
Expand Down Expand Up @@ -561,6 +565,7 @@ WorkflowModel completeWorkflow(WorkflowModel workflow) {
return workflow;
}

@PreAuthorize("hasPermission(#workflowId, 'OPERATOR')")
public void terminateWorkflow(String workflowId, String reason) {
WorkflowModel workflow = executionDAOFacade.getWorkflowModel(workflowId, true);
if (WorkflowModel.Status.COMPLETED.equals(workflow.getStatus())) {
Expand Down Expand Up @@ -1182,6 +1187,7 @@ List<TaskModel> dedupAndAddTasks(WorkflowModel workflow, List<TaskModel> tasks)
/**
* @throws ConflictException if the workflow is in terminal state.
*/
@PreAuthorize("hasPermission(#workflowId, 'OPERATOR')")
public void pauseWorkflow(String workflowId) {
try {
executionLockService.acquireLock(workflowId, 60000);
Expand Down Expand Up @@ -1217,6 +1223,7 @@ public void pauseWorkflow(String workflowId) {
* @param workflowId the workflow to be resumed
* @throws IllegalStateException if the workflow is not in PAUSED state
*/
@PreAuthorize("hasPermission(#workflowId, 'OPERATOR')")
public void resumeWorkflow(String workflowId) {
WorkflowModel workflow = executionDAOFacade.getWorkflowModel(workflowId, false);
if (!workflow.getStatus().equals(WorkflowModel.Status.PAUSED)) {
Expand Down Expand Up @@ -1245,6 +1252,7 @@ public void resumeWorkflow(String workflowId) {
* @param skipTaskRequest the {@link SkipTaskRequest} object
* @throws IllegalStateException
*/
@PreAuthorize("hasPermission(#workflowId, 'OPERATOR')")
public void skipTaskFromWorkflow(
String workflowId, String taskReferenceName, SkipTaskRequest skipTaskRequest) {

Expand Down

0 comments on commit a63c37a

Please sign in to comment.