mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 00:15:11 +01:00
feature (plg_authenticate_local): add gui toggle
This commit is contained in:
parent
79d561e2be
commit
359a6c05d1
1 changed files with 19 additions and 2 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue