From 9465f8db6d12a2bb8707f62ccb7d668059ec1cf1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 20 May 2020 13:05:05 -0400 Subject: login: set encrypted "remember me" token --- cmd/alps/main.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'cmd/alps') 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...] \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 { -- cgit v1.2.3