ExpirationOptfunc(string)error`long:"token-expiration" ini-name:"expiration" required:"false" description:"Expiration time of the generated tokens" default:"5m"`
...
...
@@ -47,6 +49,7 @@
CachePurgeDelayOptfunc(string)error`long:"token-cache-purge-delay" ini-name:"cache-purge-delay" required:"false" description:"Delay between token cache purges" default:"10m"`
returnfmt.Errorf("token-secret is not configured")
}
t.log().Warn().Msg("no secret configured. A random secret will be used, meaning authenticated session will not survice a server restart. To avoid this, please set the token-secret option")
t.Secret=make([]byte,32)
_,_=rand.Read(t.Secret)
}else{
b,err:=hex.DecodeString(t.SecretOpt)
iferr!=nil{
returnfmt.Errorf("'secret' is not a valid hex string: %w",err)
}
iflen(b)!=32{
returnfmt.Errorf("'secret' has in invalid size. Expected %d bytes, got: %d",32,len(b))