Format Code
This commit is contained in:
parent
5e8c4d4d45
commit
3634eb42a5
@ -2,15 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"github.com/asdine/storm"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
"github.com/filebrowser/filebrowser"
|
||||
"github.com/filebrowser/filebrowser/bolt"
|
||||
h "github.com/filebrowser/filebrowser/http"
|
||||
@ -18,6 +10,14 @@ import (
|
||||
"github.com/hacdias/fileutils"
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -88,7 +88,7 @@ func setupViper() {
|
||||
viper.SetDefault("StaticGen", "")
|
||||
viper.SetDefault("Locale", "")
|
||||
viper.SetDefault("AuthMethod", "default")
|
||||
viper.SetDefault("LoginHeader", "X-Fowarded-User");
|
||||
viper.SetDefault("LoginHeader", "X-Fowarded-User")
|
||||
viper.SetDefault("NoAuth", false)
|
||||
viper.SetDefault("BaseURL", "")
|
||||
viper.SetDefault("PrefixURL", "")
|
||||
@ -176,12 +176,12 @@ func main() {
|
||||
}
|
||||
|
||||
// Validate the provided config before moving forward
|
||||
if(viper.GetString("AuthMethod") != "default" && viper.GetString("AuthMethod") != "proxy") {
|
||||
if viper.GetString("AuthMethod") != "default" && viper.GetString("AuthMethod") != "proxy" {
|
||||
log.Fatal("The property 'auth.method' needs to be set to 'default' or 'proxy'.")
|
||||
}
|
||||
|
||||
if (viper.GetString("AuthMethod") == "proxy") {
|
||||
if(viper.GetString("LoginHeader") == "") {
|
||||
if viper.GetString("AuthMethod") == "proxy" {
|
||||
if viper.GetString("LoginHeader") == "" {
|
||||
log.Fatal("The 'login-header' needs to be specified when 'proxy' authentication is used.")
|
||||
}
|
||||
log.Println("[WARN] Filebrowser authentication is configured to 'proxy' authentication. This can cause a huge security issue if the infrastructure is not configured correctly.")
|
||||
|
||||
@ -181,7 +181,7 @@ func validateAuth(c *fb.Context, r *http.Request) (bool, *fb.User) {
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
c.User = u;
|
||||
c.User = u
|
||||
return true, c.User
|
||||
}
|
||||
|
||||
@ -208,4 +208,3 @@ func validateAuth(c *fb.Context, r *http.Request) (bool, *fb.User) {
|
||||
c.User = u
|
||||
return true, u
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user