Skip to content

Commit 0ba50ff

Browse files
committed
Fix inconsistent naming of OAuth 2.0 ENABLE setting
Renames it to `ENABLED` to be consistent with other settings.
1 parent 01acd1e commit 0ba50ff

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

custom/conf/app.example.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ INTERNAL_TOKEN=
524524
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
525525
;;
526526
;; Enables OAuth2 provider
527-
ENABLE = true
527+
ENABLED = true
528528
;;
529529
;; Algorithm used to sign OAuth2 tokens. Valid values: HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512, EdDSA
530530
;JWT_SIGNING_ALGORITHM = RS256

modules/setting/oauth2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func parseScopes(sec ConfigSection, name string) []string {
9393
}
9494

9595
var OAuth2 = struct {
96-
Enable bool
96+
Enabled bool
9797
AccessTokenExpirationTime int64
9898
RefreshTokenExpirationTime int64
9999
InvalidateRefreshTokens bool
@@ -103,7 +103,7 @@ var OAuth2 = struct {
103103
MaxTokenLength int
104104
DefaultApplications []string
105105
}{
106-
Enable: true,
106+
Enabled: true,
107107
AccessTokenExpirationTime: 3600,
108108
RefreshTokenExpirationTime: 730,
109109
InvalidateRefreshTokens: false,
@@ -119,7 +119,7 @@ func loadOAuth2From(rootCfg ConfigProvider) {
119119
return
120120
}
121121

122-
if !OAuth2.Enable {
122+
if !OAuth2.Enabled {
123123
return
124124
}
125125

routers/web/user/setting/applications.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ func loadApplicationsData(ctx *context.Context) {
9595
return
9696
}
9797
ctx.Data["Tokens"] = tokens
98-
ctx.Data["EnableOAuth2"] = setting.OAuth2.Enable
98+
ctx.Data["EnableOAuth2"] = setting.OAuth2.Enabled
9999
ctx.Data["IsAdmin"] = ctx.Doer.IsAdmin
100-
if setting.OAuth2.Enable {
100+
if setting.OAuth2.Enabled {
101101
ctx.Data["Applications"], err = db.Find[auth_model.OAuth2Application](ctx, auth_model.FindOAuth2ApplicationsOptions{
102102
OwnerID: ctx.Doer.ID,
103103
})

routers/web/web.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func registerRoutes(m *web.Route) {
304304
validation.AddBindingRules()
305305

306306
linkAccountEnabled := func(ctx *context.Context) {
307-
if !setting.Service.EnableOpenIDSignIn && !setting.Service.EnableOpenIDSignUp && !setting.OAuth2.Enable {
307+
if !setting.Service.EnableOpenIDSignIn && !setting.Service.EnableOpenIDSignUp && !setting.OAuth2.Enabled {
308308
ctx.Error(http.StatusForbidden)
309309
return
310310
}
@@ -768,7 +768,7 @@ func registerRoutes(m *web.Route) {
768768
m.Post("/delete", admin.DeleteApplication)
769769
})
770770
}, func(ctx *context.Context) {
771-
if !setting.OAuth2.Enable {
771+
if !setting.OAuth2.Enabled {
772772
ctx.Error(http.StatusForbidden)
773773
return
774774
}
@@ -779,7 +779,7 @@ func registerRoutes(m *web.Route) {
779779
addSettingsRunnersRoutes()
780780
addSettingsVariablesRoutes()
781781
})
782-
}, adminReq, ctxDataSet("EnableOAuth2", setting.OAuth2.Enable, "EnablePackages", setting.Packages.Enabled))
782+
}, adminReq, ctxDataSet("EnableOAuth2", setting.OAuth2.Enabled, "EnablePackages", setting.Packages.Enabled))
783783
// ***** END: Admin *****
784784

785785
m.Group("", func() {
@@ -891,7 +891,7 @@ func registerRoutes(m *web.Route) {
891891
m.Post("/delete", org.DeleteOAuth2Application)
892892
})
893893
}, func(ctx *context.Context) {
894-
if !setting.OAuth2.Enable {
894+
if !setting.OAuth2.Enabled {
895895
ctx.Error(http.StatusForbidden)
896896
return
897897
}
@@ -943,7 +943,7 @@ func registerRoutes(m *web.Route) {
943943
m.Post("/rebuild", org.RebuildCargoIndex)
944944
})
945945
}, packagesEnabled)
946-
}, ctxDataSet("EnableOAuth2", setting.OAuth2.Enable, "EnablePackages", setting.Packages.Enabled, "PageIsOrgSettings", true))
946+
}, ctxDataSet("EnableOAuth2", setting.OAuth2.Enabled, "EnablePackages", setting.Packages.Enabled, "PageIsOrgSettings", true))
947947
}, context.OrgAssignment(true, true))
948948
}, reqSignIn)
949949
// ***** END: Organization *****

0 commit comments

Comments
 (0)