// Set up process log before anything bad happens.
switchl:=viper.GetString("log");l{
case"stdout":
log.SetOutput(os.Stdout)
case"stderr":
log.SetOutput(os.Stderr)
case"":
log.SetOutput(ioutil.Discard)
default:
log.SetOutput(&lumberjack.Logger{
Filename:l,
MaxSize:100,
MaxAge:14,
MaxBackups:10,
})
}
// Validate the provided config before moving forward
{
// Map of valid authentication methods, containing a boolean value to indicate the need of Auth.Header
validMethods:=make(map[string]bool)
validMethods["none"]=false
validMethods["default"]=false
validMethods["proxy"]=true
m:=viper.GetString("auth.method")
b,ok:=validMethods[m]
if!ok{
log.Fatal("The property 'auth.method' needs to be set to 'none', 'default' or 'proxy'.")
}
ifb{
ifviper.GetString("auth.header")==""{
log.Fatal("The 'auth.header' needs to be specified when '",m,"' authentication is used.")
}
log.Println("[WARN] Filebrowser authentication is configured to '",m,"' authentication. This can cause a huge security issue if the infrastructure is not configured correctly.")