Skip to content

Commit aaf5082

Browse files
committed
Remove redundant Repo.CanWrite checks from action handlers - permissions are enforced at route level
1 parent 09c44f4 commit aaf5082

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

routers/api/v1/repo/actions_run.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ func RerunWorkflowRun(ctx *context.APIContext) {
107107
// "404":
108108
// "$ref": "#/responses/notFound"
109109

110-
if !ctx.Repo.CanWrite(unit.TypeActions) {
111-
ctx.APIError(403, "User does not have write access to actions")
112-
return
113-
}
114-
115110
_, run, err := getRunID(ctx)
116111
if err != nil {
117112
if errors.Is(err, util.ErrNotExist) {
@@ -192,11 +187,6 @@ func CancelWorkflowRun(ctx *context.APIContext) {
192187
// "404":
193188
// "$ref": "#/responses/notFound"
194189

195-
if !ctx.Repo.CanWrite(unit.TypeActions) {
196-
ctx.APIError(403, "User does not have write access to actions")
197-
return
198-
}
199-
200190
runID, _, err := getRunID(ctx)
201191
if err != nil {
202192
if errors.Is(err, util.ErrNotExist) {
@@ -293,11 +283,6 @@ func ApproveWorkflowRun(ctx *context.APIContext) {
293283
// "404":
294284
// "$ref": "#/responses/notFound"
295285

296-
if !ctx.Repo.CanWrite(unit.TypeActions) {
297-
ctx.APIError(403, "User does not have write access to actions")
298-
return
299-
}
300-
301286
runID, _, err := getRunID(ctx)
302287
if err != nil {
303288
if errors.Is(err, util.ErrNotExist) {
@@ -396,11 +381,6 @@ func RerunWorkflowJob(ctx *context.APIContext) {
396381
// "404":
397382
// "$ref": "#/responses/notFound"
398383

399-
if !ctx.Repo.CanWrite(unit.TypeActions) {
400-
ctx.APIError(403, "User does not have write access to actions")
401-
return
402-
}
403-
404384
runID, _, err := getRunID(ctx)
405385
if err != nil {
406386
if errors.Is(err, util.ErrNotExist) {

0 commit comments

Comments
 (0)