Generate JWT secret when env var is empty

This commit is contained in:
Denis Arh
2019-06-19 17:53:20 +02:00
parent 59d315c079
commit 837ce2514f
+5 -3
View File
@@ -15,13 +15,15 @@ type (
func JWT(pfix string) (o *JWTOpt) {
o = &JWTOpt{
// Setting JWT secret to random string to prevent security accidents...
Secret: string(rand.Bytes(32)),
Expiry: time.Hour * 24 * 30,
}
fill(o, pfix)
// Setting JWT secret to random string to prevent security accidents...
if o.Secret == "" {
o.Secret = string(rand.Bytes(32))
}
return
}