From 359a6c05d134bc7c9f3b60eb8c98b39d51d59c9f Mon Sep 17 00:00:00 2001 From: MickaelK Date: Tue, 25 Nov 2025 14:00:55 +1100 Subject: [PATCH] feature (plg_authenticate_local): add gui toggle --- server/plugin/plg_authenticate_local/data.go | 21 ++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/server/plugin/plg_authenticate_local/data.go b/server/plugin/plg_authenticate_local/data.go index b0d16776..50141e28 100644 --- a/server/plugin/plg_authenticate_local/data.go +++ b/server/plugin/plg_authenticate_local/data.go @@ -2,13 +2,20 @@ package plg_authenticate_local import ( "encoding/json" + "os" . "github.com/mickael-kerjean/filestash/server/common" ) +var force bool + +func init() { + force = os.Getenv("PLG_AUTHENTICATE_LOCAL_ENABLED") == "true" +} + func getPluginData() (pluginConfig, error) { var cfg pluginConfig - if Config.Get("middleware.identity_provider.type").String() != "local" { + if !isEnabled() { Log.Warning("plg_authenticate_simple::disable msg=middleware_is_not_enabled") return cfg, ErrMissingDependency } @@ -30,7 +37,7 @@ func getPluginData() (pluginConfig, error) { } func savePluginData(cfg pluginConfig) error { - if Config.Get("middleware.identity_provider.type").String() != "local" { + if !isEnabled() { Log.Warning("plg_authenticate_simple::disable msg=middleware_is_not_enabled") return ErrMissingDependency } @@ -46,3 +53,13 @@ func savePluginData(cfg pluginConfig) error { Config.Get("middleware.identity_provider.params").Set(string(b)) return nil } + +func isEnabled() bool { + if Config.Get("middleware.identity_provider.type").String() == "local" { + return true + } else if force { + return true + } + Log.Warning("plg_authenticate_simple::disable msg=middleware_is_not_enabled") + return false +}