diff --git a/models/actions/config.go b/models/actions/config.go index 7bd64b74d4..45d248af65 100644 --- a/models/actions/config.go +++ b/models/actions/config.go @@ -22,6 +22,7 @@ func GetOrgActionsConfig(ctx context.Context, orgID int64) (*repo_model.ActionsC cfg := &repo_model.ActionsConfig{} if val == "" { // Return defaults if no config exists + cfg.AllowCrossRepoAccess = true return cfg, nil } diff --git a/models/perm/access/repo_permission.go b/models/perm/access/repo_permission.go index f76ea20b5c..8844e5bad2 100644 --- a/models/perm/access/repo_permission.go +++ b/models/perm/access/repo_permission.go @@ -311,15 +311,16 @@ func GetActionsUserRepoPermission(ctx context.Context, repo *repo_model.Reposito // The task repo can access the current repo only if the task repo is private and // the owner of the task repo is a collaborative owner of the current repo. // FIXME should owner's visibility also be considered here? + // + // If not, we check if they are in the same org and cross-repo access is allowed. + // If allowed, we grant Read Access (consistent with old behavior and package access). + // If NOT allowed (checked above for sameOrg), we fall through to here. - // check permission like simple user but limit to read-only - perm, err = GetUserRepoPermission(ctx, repo, user_model.NewActionsUser()) - if err != nil { - return perm, err + if !isSameOrg { + return perm, nil } - perm.AccessMode = min(perm.AccessMode, perm_model.AccessModeRead) - return perm, nil } + // Cross-repo access is always read-only perm.SetUnitsWithDefaultAccessMode(repo.Units, perm_model.AccessModeRead) return perm, nil diff --git a/models/repo/repo_unit.go b/models/repo/repo_unit.go index a36f8096e2..db92d52a61 100644 --- a/models/repo/repo_unit.go +++ b/models/repo/repo_unit.go @@ -303,9 +303,6 @@ type ActionsConfig struct { CollaborativeOwnerIDs []int64 // TokenPermissionMode defines the default permission mode (permissive, restricted, or custom) TokenPermissionMode ActionsTokenPermissionMode `json:"token_permission_mode,omitempty"` - // DefaultTokenPermissions defines the specific permissions for workflow tokens when TokenPermissionMode is set to "custom" - // and no "permissions" keyword is defined in the workflow YAML. - DefaultTokenPermissions *ActionsTokenPermissions `json:"default_token_permissions,omitempty"` // MaxTokenPermissions defines the absolute maximum permissions any token can have in this context. // Workflow YAML "permissions" keywords can reduce permissions but never exceed this ceiling. MaxTokenPermissions *ActionsTokenPermissions `json:"max_token_permissions,omitempty"` @@ -366,9 +363,8 @@ func (cfg *ActionsConfig) GetEffectiveTokenPermissions(isForkPullRequest bool) A return ForkPullRequestPermissions() } - // Use custom default permissions if set - if cfg.DefaultTokenPermissions != nil { - return *cfg.DefaultTokenPermissions + if cfg.GetTokenPermissionMode() == ActionsTokenPermissionModeCustom { + return cfg.GetMaxTokenPermissions() } // Otherwise use mode-based defaults diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 39e2a729bd..852154de17 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -3731,6 +3731,7 @@ "git.filemode.executable_file": "Executable", "git.filemode.symbolic_link": "Symlink", "git.filemode.submodule": "Submodule", + "org.repos.none": "No repositories.", "actions.general.token_permissions.title": "Action Token Permissions", "actions.general.token_permissions.desc": "Configure the default permissions for the GITEA_TOKEN running in this repository.", "actions.general.token_permissions.mode": "Default Token Permissions", @@ -3744,7 +3745,7 @@ "actions.general.token_permissions.access_read": "Read", "actions.general.token_permissions.access_write": "Write", "actions.general.token_permissions.code": "Code", - "actions.general.token_permissions.code.description": "Repository contents, commits, branches, downloads, releases, and merges.", + "actions.general.token_permissions.code.description": "Repository contents, commits, branches, downloads, and merges.", "actions.general.token_permissions.issues": "Issues", "actions.general.token_permissions.issues.description": "Issues and related comments, assignees, labels, and milestones.", "actions.general.token_permissions.pull_requests": "Pull Requests", diff --git a/templates/org/settings/actions_general.tmpl b/templates/org/settings/actions_general.tmpl index 0e38c0bdfb..c1d537d29f 100644 --- a/templates/org/settings/actions_general.tmpl +++ b/templates/org/settings/actions_general.tmpl @@ -52,10 +52,7 @@