mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-24 05:39:46 +02:00
Implement Workflow Level Permissions
This commit is contained in:
1 parent
f367039e78
commit
1ff75aa822
7 files changed
+463
-3
No files matched your search
@@ -325,9 +325,25 @@ func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Reposito
|
||||
return perm, nil
|
||||
}
|
||||
|
||||
// Get effective token permissions from repository settings
|
||||
effectivePerms := actionsCfg.GetEffectiveTokenPermissions(task.IsForkPullRequest)
|
||||
effectivePerms = actionsCfg.ClampPermissions(effectivePerms)
|
||||
// Get effective token permissions
|
||||
// First check if job has explicit permissions stored from workflow YAML
|
||||
var effectivePerms repo_model.ActionsTokenPermissions
|
||||
if err := task.LoadJob(ctx); err != nil {
|
||||
return perm, err
|
||||
}
|
||||
if task.Job != nil && task.Job.TokenPermissions != "" {
|
||||
// Use permissions parsed from workflow YAML (already clamped by repo max settings during insertion)
|
||||
effectivePerms, err = repo_model.UnmarshalTokenPermissions(task.Job.TokenPermissions)
|
||||
if err != nil {
|
||||
// Fall back to repository settings if unmarshal fails
|
||||
effectivePerms = actionsCfg.GetEffectiveTokenPermissions(task.IsForkPullRequest)
|
||||
effectivePerms = actionsCfg.ClampPermissions(effectivePerms)
|
||||
}
|
||||
} else {
|
||||
// No workflow permissions, use repository settings
|
||||
effectivePerms = actionsCfg.GetEffectiveTokenPermissions(task.IsForkPullRequest)
|
||||
effectivePerms = actionsCfg.ClampPermissions(effectivePerms)
|
||||
}
|
||||
|
||||
// Set up per-unit access modes based on configured permissions
|
||||
perm.units = repo.Units
|
||||
|
||||
Reference in new issue
Block a user