mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-02 00:18:35 +01:00
Fix incorrect setting loading order (#36735)
This commit is contained in:
@@ -29,8 +29,10 @@ func TestShortSha(t *testing.T) {
|
|||||||
func TestVerifyTimeLimitCode(t *testing.T) {
|
func TestVerifyTimeLimitCode(t *testing.T) {
|
||||||
defer test.MockVariableValue(&setting.InstallLock, true)()
|
defer test.MockVariableValue(&setting.InstallLock, true)()
|
||||||
initGeneralSecret := func(secret string) {
|
initGeneralSecret := func(secret string) {
|
||||||
setting.InstallLock = true
|
|
||||||
setting.CfgProvider, _ = setting.NewConfigProviderFromData(fmt.Sprintf(`
|
setting.CfgProvider, _ = setting.NewConfigProviderFromData(fmt.Sprintf(`
|
||||||
|
[security]
|
||||||
|
INTERNAL_TOKEN = dummy
|
||||||
|
INSTALL_LOCK = true
|
||||||
[oauth2]
|
[oauth2]
|
||||||
JWT_SECRET = %s
|
JWT_SECRET = %s
|
||||||
`, secret))
|
`, secret))
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ func generateSaveInternalToken(rootCfg ConfigProvider) {
|
|||||||
|
|
||||||
func loadSecurityFrom(rootCfg ConfigProvider) {
|
func loadSecurityFrom(rootCfg ConfigProvider) {
|
||||||
sec := rootCfg.Section("security")
|
sec := rootCfg.Section("security")
|
||||||
InstallLock = HasInstallLock(rootCfg)
|
|
||||||
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(31)
|
LogInRememberDays = sec.Key("LOGIN_REMEMBER_DAYS").MustInt(31)
|
||||||
SecretKey = loadSecret(sec, "SECRET_KEY_URI", "SECRET_KEY")
|
SecretKey = loadSecret(sec, "SECRET_KEY_URI", "SECRET_KEY")
|
||||||
if SecretKey == "" {
|
if SecretKey == "" {
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ func LoadCommonSettings() {
|
|||||||
|
|
||||||
// loadCommonSettingsFrom loads common configurations from a configuration provider.
|
// loadCommonSettingsFrom loads common configurations from a configuration provider.
|
||||||
func loadCommonSettingsFrom(cfg ConfigProvider) error {
|
func loadCommonSettingsFrom(cfg ConfigProvider) error {
|
||||||
|
// a lot of logic depends on InstallLock value, so it must be loaded before any other settings
|
||||||
|
InstallLock = HasInstallLock(cfg)
|
||||||
|
|
||||||
// WARNING: don't change the sequence except you know what you are doing.
|
// WARNING: don't change the sequence except you know what you are doing.
|
||||||
loadRunModeFrom(cfg)
|
loadRunModeFrom(cfg)
|
||||||
loadLogGlobalFrom(cfg)
|
loadLogGlobalFrom(cfg)
|
||||||
|
|||||||
Reference in New Issue
Block a user