From 72f08a149b72c400ebeaa6b10c6a263d19157395 Mon Sep 17 00:00:00 2001 From: Yarden Shoham Date: Sun, 14 Jan 2024 18:15:52 +0000 Subject: [PATCH] Warn that `DISABLE_QUERY_AUTH_TOKEN` is false only if it's explicitly defined So we don't warn on default behavior Signed-off-by: Yarden Shoham --- modules/setting/security.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/setting/security.go b/modules/setting/security.go index 4adfe20635e77..380360a696ffa 100644 --- a/modules/setting/security.go +++ b/modules/setting/security.go @@ -159,10 +159,13 @@ func loadSecurityFrom(rootCfg ConfigProvider) { } } + sectionHasDisableQueryAuthToken := sec.HasKey("DISABLE_QUERY_AUTH_TOKEN") + // TODO: default value should be true in future releases DisableQueryAuthToken = sec.Key("DISABLE_QUERY_AUTH_TOKEN").MustBool(false) - if !DisableQueryAuthToken { + // warn if the setting is set to false explicitly + if sectionHasDisableQueryAuthToken && !DisableQueryAuthToken { log.Warn("Enabling Query API Auth tokens is not recommended. DISABLE_QUERY_AUTH_TOKEN will default to true in gitea 1.23 and will be removed in gitea 1.24.") } }