@@ -49,6 +49,15 @@ const (
49
49
tplDeployKeys templates.TplName = "repo/settings/deploy_keys"
50
50
)
51
51
52
+ func parseFormAccessMode (permission string , allowed ... perm.AccessMode ) perm.AccessMode {
53
+ // if site admin forces repositories to be private, then do not allow any other access mode,
54
+ // otherwise the "force private" setting would be bypassed
55
+ if setting .Repository .ForcePrivate {
56
+ return perm .AccessModeNone
57
+ }
58
+ return perm .ParseAccessMode (permission , allowed ... )
59
+ }
60
+
52
61
// SettingsCtxData is a middleware that sets all the general context data for the
53
62
// settings template.
54
63
func SettingsCtxData (ctx * context.Context ) {
@@ -449,7 +458,7 @@ func SettingsPost(ctx *context.Context) {
449
458
units = append (units , repo_model.RepoUnit {
450
459
RepoID : repo .ID ,
451
460
Type : unit_model .TypeCode ,
452
- EveryoneAccessMode : perm . ParseAccessMode (form .DefaultCodeEveryoneAccess , perm .AccessModeNone , perm .AccessModeRead ),
461
+ EveryoneAccessMode : parseFormAccessMode (form .DefaultCodeEveryoneAccess , perm .AccessModeNone , perm .AccessModeRead ),
453
462
})
454
463
} else if ! unit_model .TypeCode .UnitGlobalDisabled () {
455
464
deleteUnitTypes = append (deleteUnitTypes , unit_model .TypeCode )
@@ -475,7 +484,7 @@ func SettingsPost(ctx *context.Context) {
475
484
RepoID : repo .ID ,
476
485
Type : unit_model .TypeWiki ,
477
486
Config : new (repo_model.UnitConfig ),
478
- EveryoneAccessMode : perm . ParseAccessMode (form .DefaultWikiEveryoneAccess , perm .AccessModeNone , perm .AccessModeRead , perm .AccessModeWrite ),
487
+ EveryoneAccessMode : parseFormAccessMode (form .DefaultWikiEveryoneAccess , perm .AccessModeNone , perm .AccessModeRead , perm .AccessModeWrite ),
479
488
})
480
489
deleteUnitTypes = append (deleteUnitTypes , unit_model .TypeExternalWiki )
481
490
} else {
@@ -525,7 +534,7 @@ func SettingsPost(ctx *context.Context) {
525
534
AllowOnlyContributorsToTrackTime : form .AllowOnlyContributorsToTrackTime ,
526
535
EnableDependencies : form .EnableIssueDependencies ,
527
536
},
528
- EveryoneAccessMode : perm . ParseAccessMode (form .DefaultIssuesEveryoneAccess , perm .AccessModeNone , perm .AccessModeRead ),
537
+ EveryoneAccessMode : parseFormAccessMode (form .DefaultIssuesEveryoneAccess , perm .AccessModeNone , perm .AccessModeRead ),
529
538
})
530
539
deleteUnitTypes = append (deleteUnitTypes , unit_model .TypeExternalTracker )
531
540
} else {
0 commit comments