@@ -34,14 +34,10 @@ func GetActionsPermissions(ctx *context.APIContext) {
3434 // Organization settings are more sensitive than repo settings because they
3535 // affect ALL repositories in the org. We should be extra careful here.
3636 // Only org owners should be able to modify these settings.
37- isOwner , err := ctx .Org .Organization .IsOwnedBy (ctx , ctx .Doer .ID )
38- if err != nil {
39- ctx .APIErrorInternal (err )
40- return
41- } else if ! isOwner {
42- ctx .APIError (http .StatusForbidden , "You must be an organization owner" )
43- return
44- }
37+ // Organization settings are more sensitive than repo settings because they
38+ // affect ALL repositories in the org. We should be extra careful here.
39+ // Only org owners should be able to modify these settings.
40+ // This is enforced by the reqOrgOwnership middleware.
4541
4642 perms , err := actions_model .GetOrgActionPermissions (ctx , ctx .Org .Organization .ID )
4743 if err != nil {
@@ -90,14 +86,10 @@ func UpdateActionsPermissions(ctx *context.APIContext) {
9086 // "403":
9187 // "$ref": "#/responses/forbidden"
9288
93- isOwner , err := ctx .Org .Organization .IsOwnedBy (ctx , ctx .Doer .ID )
94- if err != nil {
95- ctx .APIError (http .StatusInternalServerError , err )
96- return
97- } else if ! isOwner {
98- ctx .APIError (http .StatusForbidden , "Organization owner access required" )
99- return
100- }
89+ // Organization settings are more sensitive than repo settings because they
90+ // affect ALL repositories in the org. We should be extra careful here.
91+ // Only org owners should be able to modify these settings.
92+ // This is enforced by the reqOrgOwnership middleware.
10193
10294 form := web .GetForm (ctx ).(* api.OrgActionsPermissions )
10395
@@ -160,20 +152,13 @@ func ListCrossRepoAccess(ctx *context.APIContext) {
160152 // "200":
161153 // "$ref": "#/responses/CrossRepoAccessList"
162154
163- isOwner , err := ctx .Org .Organization .IsOwnedBy (ctx , ctx .Doer .ID )
164- if err != nil {
165- ctx .APIErrorInternal (err )
166- return
167- }
168- if ! isOwner {
169- ctx .APIError (http .StatusForbidden , "Organization owner access required" )
170- return
171- }
172-
173155 // This is a critical security feature - cross-repo access allows one repo's
174156 // Actions to access another repo's code/resources. We need to be very careful
175157 // about how we implement this. See the discussion:
176158 // https://github.com/go-gitea/gitea/issues/24635
159+ // Permission check handled by reqOrgOwnership middleware
160+
161+
177162
178163 rules , err := actions_model .ListCrossRepoAccessRules (ctx , ctx .Org .Organization .ID )
179164 if err != nil {
@@ -214,15 +199,7 @@ func AddCrossRepoAccess(ctx *context.APIContext) {
214199 // "403":
215200 // "$ref": "#/responses/forbidden"
216201
217- isOwner , err := ctx .Org .Organization .IsOwnedBy (ctx , ctx .Doer .ID )
218- if err != nil {
219- ctx .APIErrorInternal (err )
220- return
221- }
222- if ! isOwner {
223- ctx .APIError (http .StatusForbidden , "Organization owner access required" )
224- return
225- }
202+ // Permission check handled by reqOrgOwnership middleware
226203
227204 form := web .GetForm (ctx ).(* api.CrossRepoAccessRule )
228205
@@ -274,16 +251,7 @@ func DeleteCrossRepoAccess(ctx *context.APIContext) {
274251 // "403":
275252 // "$ref": "#/responses/forbidden"
276253
277- isOwner , err := ctx .Org .Organization .IsOwnedBy (ctx , ctx .Doer .ID )
278- if err != nil {
279- ctx .APIErrorInternal (err )
280- return
281- }
282- if ! isOwner {
283- ctx .APIError (http .StatusForbidden , "Organization owner access required" )
284- return
285- }
286-
254+ // Permission check handled by reqOrgOwnership middleware
287255 ruleID := ctx .PathParamInt64 ("id" )
288256
289257 // Security check: Verify the rule belongs to this org before deleting
0 commit comments