Skip to content

Commit 1119fee

Browse files
committed
rename loadSecret to loadOrGenerateSecret and add more comments
1 parent 811d1de commit 1119fee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

modules/setting/setting.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -925,11 +925,9 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
925925
InstallLock = sec.Key("INSTALL_LOCK").MustBool(false)
926926
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(7)
927927
CookieUserName = sec.Key("COOKIE_USERNAME").MustString("gitea_awesome")
928-
SecretKey = loadSecret(sec, "SECRET_KEY_URI", "SECRET_KEY", func() (string, error) {
928+
SecretKey = loadOrGenerateSecret(sec, "SECRET_KEY_URI", "SECRET_KEY", func() (string, error) {
929929
// FIXME: https://github.com/go-gitea/gitea/issues/16832
930-
//
931-
// Until we properly support rotating an existing secret key,
932-
// we shouldn't move users off of the default value
930+
// Until it supports rotating an existing secret key, we shouldn't move users off of the widely used default value
933931
return "!#@FDEWREWR&*(", nil
934932
})
935933

@@ -955,7 +953,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
955953
PasswordCheckPwn = sec.Key("PASSWORD_CHECK_PWN").MustBool(false)
956954
SuccessfulTokensCacheSize = sec.Key("SUCCESSFUL_TOKENS_CACHE_SIZE").MustInt(20)
957955

958-
InternalToken = loadSecret(sec, "INTERNAL_TOKEN_URI", "INTERNAL_TOKEN", generate.NewInternalToken)
956+
InternalToken = loadOrGenerateSecret(sec, "INTERNAL_TOKEN_URI", "INTERNAL_TOKEN", generate.NewInternalToken)
959957

960958
cfgdata := sec.Key("PASSWORD_COMPLEXITY").Strings(",")
961959
if len(cfgdata) == 0 {
@@ -1144,7 +1142,9 @@ func parseAuthorizedPrincipalsAllow(values []string) ([]string, bool) {
11441142
return authorizedPrincipalsAllow, true
11451143
}
11461144

1147-
func loadSecret(
1145+
// loadOrGenerateSecret loads the secret if it exists in the config file,
1146+
// or generates a new one and saves it into the config file
1147+
func loadOrGenerateSecret(
11481148
sec *ini.Section,
11491149
uriKey string,
11501150
verbatimKey string,

0 commit comments

Comments
 (0)