From f17b8179b6ccf32a5a6065d482ad8608baf38486 Mon Sep 17 00:00:00 2001 From: boyska Date: Tue, 13 Nov 2018 14:51:07 +0100 Subject: [PATCH] userpanel: add cli params --- cmd/userpanel/main.go | 19 +++++++++++++++---- go.mod | 1 + go.sum | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cmd/userpanel/main.go b/cmd/userpanel/main.go index 4a5de15..8e1b021 100644 --- a/cmd/userpanel/main.go +++ b/cmd/userpanel/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "net/http" @@ -9,10 +10,20 @@ import ( ) func main() { - ha := panelui.HeaderAuth{AllowedNames: []string{"feedati-fe"}, RequireUser: true} + allowedName := flag.String("allowed-name", "", "Name allowed to forward auth") + addr := flag.String("listen-addr", ":8000", "Address to listen on") + flag.Parse() + + var allowedNames []string + if *allowedName != "" { + allowedNames = []string{*allowedName} + } else { + allowedNames = []string{} + } + + ha := panelui.HeaderAuth{AllowedNames: allowedNames, RequireUser: true} n := negroni.New(negroni.NewRecovery(), negroni.NewLogger(), ha) n.UseHandler(panelui.GetMux()) - addr := ":8000" - fmt.Println("Listening on", addr) - http.ListenAndServe(addr, n) + fmt.Println("Listening on", *addr) + http.ListenAndServe(*addr, n) } diff --git a/go.mod b/go.mod index 8968a3a..c93bc57 100644 --- a/go.mod +++ b/go.mod @@ -8,6 +8,7 @@ require ( github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a // indirect github.com/kardianos/osext v0.0.0-20170510131534-ae77be60afb1 // indirect github.com/kr/pretty v0.1.0 // indirect + github.com/namsral/flag v1.7.4-pre github.com/onsi/gomega v1.4.2 // indirect github.com/pkg/errors v0.8.0 github.com/urfave/negroni v1.0.0 diff --git a/go.sum b/go.sum index 09f449d..24c1bb9 100644 --- a/go.sum +++ b/go.sum @@ -21,6 +21,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/namsral/flag v1.7.4-pre h1:b2ScHhoCUkbsq0d2C15Mv+VU8bl8hAXV8arnWiOHNZs= +github.com/namsral/flag v1.7.4-pre/go.mod h1:OXldTctbM6SWH1K899kPZcf65KxJiD7MsceFUpB5yDo= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=