Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
fix(workflow): project member rbac
Browse files Browse the repository at this point in the history
Project members in the Member role do not have permission to create workflows and approve tasks #1378
  • Loading branch information
alexcodelf authored and aiwantaozi committed Nov 10, 2023
1 parent 4274a88 commit 2e61212
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
20 changes: 20 additions & 0 deletions pkg/apis/workflowexecution/basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,23 @@ func (h Handler) CollectionGet(req CollectionGetRequest) (CollectionGetResponse,

return model.ExposeWorkflowExecutions(entities), count, nil
}

func (h Handler) Delete(req DeleteRequest) error {
return h.modelClient.WorkflowExecutions().DeleteOneID(req.ID).
Exec(req.Context)
}

func (h Handler) CollectionDelete(req CollectionDeleteRequest) error {
ids := req.IDs()

return h.modelClient.WithTx(req.Context, func(tx *model.Tx) error {
_, err := tx.WorkflowStepExecutions().Delete().
Where(workflowstepexecution.IDIn(ids...)).
Exec(req.Context)
if err != nil {
return err
}

return nil
})
}
14 changes: 14 additions & 0 deletions pkg/apis/workflowexecution/basic_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,17 @@ type (
func (r *CollectionGetRequest) SetStream(stream runtime.RequestUnidiStream) {
r.Stream = &stream
}

type (
DeleteRequest struct {
model.WorkflowExecutionQueryInput `path:",inline"`
}

DeleteResponse = *model.WorkflowExecutionDeleteInput
)

func (r *DeleteRequest) Validate() error {
return r.WorkflowExecutionQueryInput.Validate()
}

type CollectionDeleteRequest = model.WorkflowExecutionDeleteInputs
12 changes: 6 additions & 6 deletions pkg/server/init_rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,7 @@ func createRoles(ctx context.Context, mc model.ClientSet) error {
"projects",
"projectSubjects",
"templates",
"templateVersions",
"workflows",
"workflowExecutions",
"workflowStageExecutions",
"workflowStepExecutions"),
"templateVersions"),
},
{
Actions: types.RolePolicyFields("*"),
Expand All @@ -218,7 +214,11 @@ func createRoles(ctx context.Context, mc model.ClientSet) error {
"resources",
"resourceComponents",
"resourceRevisions",
"variables"),
"variables",
"workflows",
"workflowExecutions",
"workflowStageExecutions",
"workflowStepExecutions"),
},
{
Actions: types.RolePolicyFields(http.MethodPost),
Expand Down

0 comments on commit 2e61212

Please sign in to comment.