@@ -17,6 +17,7 @@ import (
1717 "strconv"
1818 "strings"
1919
20+ actions_model "code.gitea.io/gitea/models/actions"
2021 git_model "code.gitea.io/gitea/models/git"
2122 "code.gitea.io/gitea/models/perm"
2223 access_model "code.gitea.io/gitea/models/perm/access"
@@ -495,10 +496,27 @@ func authenticate(ctx *context.Context, repository *repo_model.Repository, autho
495496 accessMode = perm .AccessModeWrite
496497 }
497498
499+ if ctx .Data ["IsActionsToken" ] == true {
500+ taskID := ctx .Data ["ActionsTaskID" ].(int64 )
501+ task , err := actions_model .GetTaskByID (ctx , taskID )
502+ if err != nil {
503+ log .Error ("Unable to GetTaskByID for task[%d] Error: %v" , taskID , err )
504+ return false
505+ }
506+ if task .RepoID != repository .ID {
507+ return false
508+ }
509+
510+ if task .IsForkPullRequest {
511+ return accessMode <= perm .AccessModeRead
512+ }
513+ return accessMode <= perm .AccessModeWrite
514+ }
515+
498516 // ctx.IsSigned is unnecessary here, this will be checked in perm.CanAccess
499517 perm , err := access_model .GetUserRepoPermission (ctx , repository , ctx .Doer )
500518 if err != nil {
501- log .Error ("Unable to GetUserRepoPermission for user %-v in repo %-v Error: %v" , ctx .Doer , repository )
519+ log .Error ("Unable to GetUserRepoPermission for user %-v in repo %-v Error: %v" , ctx .Doer , repository , err )
502520 return false
503521 }
504522
0 commit comments