loginsrv

Unnamed repository; edit this file 'description' to name the repository.
git clone git@jamesshield.xyz:repos/loginsrv.git
Log | Files | Refs | README | LICENSE

commit aa943b53de20f9840d12d39d289597e7c46e252d
parent 4fe9c1b9bddcd73193592c80e748384a46310e77
Author: Sebastian Mancke <s.mancke@tarent.de>
Date:   Tue, 14 Nov 2017 20:15:03 +0100

Merge pull request #56 from lhopki01/master

Fix issue with jwt secret defaulting to "random key" in caddy if not specified by JWT_SECRET
Diffstat:
Mlogin/config.go | 16+++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/login/config.go b/login/config.go @@ -4,12 +4,13 @@ import ( "errors" "flag" "fmt" - "github.com/tarent/loginsrv/logging" - "github.com/tarent/loginsrv/oauth2" "math/rand" "os" "strings" "time" + + "github.com/tarent/loginsrv/logging" + "github.com/tarent/loginsrv/oauth2" ) var jwtDefaultSecret string @@ -95,7 +96,7 @@ func (c *Config) ConfigureFlagSet(f *flag.FlagSet) { f.StringVar(&c.Port, "port", c.Port, "The port to listen on") f.StringVar(&c.LogLevel, "log-level", c.LogLevel, "The log level") f.BoolVar(&c.TextLogging, "text-logging", c.TextLogging, "Log in text format instead of json") - f.StringVar(&c.JwtSecret, "jwt-secret", "random key", "The secret to sign the jwt token") + f.StringVar(&c.JwtSecret, "jwt-secret", c.JwtSecret, "The secret to sign the jwt token") f.DurationVar(&c.JwtExpiry, "jwt-expiry", c.JwtExpiry, "The expiry duration for the jwt token, e.g. 2h or 3h30m") f.IntVar(&c.JwtRefreshes, "jwt-refreshes", c.JwtRefreshes, "The maximum amount of jwt refreshes. 0 by Default") f.StringVar(&c.CookieName, "cookie-name", c.CookieName, "The name of the jwt cookie") @@ -168,19 +169,12 @@ func readConfig(f *flag.FlagSet, args []string) (*Config, error) { } }) + // prefer flags over environment settings err := f.Parse(args) if err != nil { return nil, err } - if config.JwtSecret == "random key" { - if s, set := os.LookupEnv("LOGINSRV_JWT_SECRET"); set { - config.JwtSecret = s - } else { - config.JwtSecret = jwtDefaultSecret - } - } - return config, err }