Allow for static secret
This commit is contained in:
parent
dc2b5e8fb5
commit
387b89963d
2 changed files with 9 additions and 4 deletions
7
internal/env/env.go
vendored
7
internal/env/env.go
vendored
|
@ -19,10 +19,11 @@ type Config struct {
|
||||||
WeatherUnits string `env:"WEATHER_UNITS" envDefault:"metric"`
|
WeatherUnits string `env:"WEATHER_UNITS" envDefault:"metric"`
|
||||||
WeatherLanguage string `env:"WEATHER_LANG" envDefault:"en" validate:"bcp47_language_tag"`
|
WeatherLanguage string `env:"WEATHER_LANG" envDefault:"en" validate:"bcp47_language_tag"`
|
||||||
WeatherDigits bool `env:"WEATHER_DIGITS" envDefault:"false"`
|
WeatherDigits bool `env:"WEATHER_DIGITS" envDefault:"false"`
|
||||||
AuthClientID string `env:"AUTH_CLIENT_ID"`
|
AuthClientID string `env:"AUTH_CLIENT_ID" validate:"required"`
|
||||||
AuthClientSecret string `env:"AUTH_CLIENT_SECRET"`
|
AuthClientSecret string `env:"AUTH_CLIENT_SECRET" validate:"required"`
|
||||||
AuthScopes []string `env:"AUTH_SCOPES" envSeparator:"," envDefault:"openid,email,profile"`
|
AuthScopes []string `env:"AUTH_SCOPES" envSeparator:"," envDefault:"openid,email,profile"`
|
||||||
AuthIssuer string `env:"AUTH_ISSUER"`
|
AuthIssuer string `env:"AUTH_ISSUER" validate:"required,url,endsnotwith=/.well-known/openid-configuration"`
|
||||||
|
SessionKey string `env:"SESSION_KEY,unset"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var errParse = errors.New("error parsing environment variables")
|
var errParse = errors.New("error parsing environment variables")
|
||||||
|
|
6
main.go
6
main.go
|
@ -33,7 +33,11 @@ func main() {
|
||||||
b := services.NewBookmarkService()
|
b := services.NewBookmarkService()
|
||||||
|
|
||||||
parsedUrl, _ := url.Parse(env.PublicUrl)
|
parsedUrl, _ := url.Parse(env.PublicUrl)
|
||||||
store := sessions.NewCookieStore(securecookie.GenerateRandomKey(32))
|
secret := []byte(env.SessionKey)
|
||||||
|
if len(secret) == 0 {
|
||||||
|
secret = securecookie.GenerateRandomKey(32)
|
||||||
|
}
|
||||||
|
store := sessions.NewCookieStore(secret)
|
||||||
store.Options = &sessions.Options{
|
store.Options = &sessions.Options{
|
||||||
Domain: parsedUrl.Hostname(),
|
Domain: parsedUrl.Hostname(),
|
||||||
MaxAge: 86400 * 30,
|
MaxAge: 86400 * 30,
|
||||||
|
|
Loading…
Reference in a new issue