diff options
author | Drew DeVault <sir@cmpwn.com> | 2020-05-20 13:05:05 -0400 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-05-20 19:07:47 +0200 |
commit | 9465f8db6d12a2bb8707f62ccb7d668059ec1cf1 (patch) | |
tree | 479c7dcca50c06008a85e5b95d6b36c8c713003c /cmd/alps | |
parent | ee3f66c24c3a8fba4ee1867e15f7c0814abdb100 (diff) | |
download | alps-9465f8db6d12a2bb8707f62ccb7d668059ec1cf1.tar.gz alps-9465f8db6d12a2bb8707f62ccb7d668059ec1cf1.zip |
login: set encrypted "remember me" token
Diffstat (limited to 'cmd/alps')
-rw-r--r-- | cmd/alps/main.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/cmd/alps/main.go b/cmd/alps/main.go index c0b77f2..4c358d5 100644 --- a/cmd/alps/main.go +++ b/cmd/alps/main.go @@ -8,6 +8,7 @@ import ( "syscall" "git.sr.ht/~emersion/alps" + "github.com/fernet/fernet-go" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" "github.com/labstack/gommon/log" @@ -21,11 +22,15 @@ import ( ) func main() { - var options alps.Options - var addr string + var ( + addr string + loginKey string + options alps.Options + ) flag.StringVar(&options.Theme, "theme", "", "default theme") flag.StringVar(&addr, "addr", ":1323", "listening address") flag.BoolVar(&options.Debug, "debug", false, "enable debug logs") + flag.StringVar(&loginKey, "login-key", "", "Fernet key for login persistence") flag.Usage = func() { fmt.Fprintf(flag.CommandLine.Output(), "usage: alps [options...] <upstream servers...>\n") @@ -40,6 +45,15 @@ func main() { return } + if loginKey != "" { + fernetKey, err := fernet.DecodeKey(loginKey) + if err != nil { + flag.Usage() + return + } + options.LoginKey = fernetKey + } + e := echo.New() e.HideBanner = true if l, ok := e.Logger.(*log.Logger); ok { |