Generate a secret key in debug only if it is zero.

This prevents printing a secret key warning if a secret key was
generated, as is done by Rocket itself. This does not change any
behaviors in non-debug profiles.
This commit is contained in:
Sergio Benitez 2021-03-10 02:13:50 -08:00
parent c9d7b4fbe0
commit bc38196f8d
1 changed files with 2 additions and 2 deletions

View File

@ -538,11 +538,11 @@ impl Rocket {
let profile = self.figment.profile();
if profile != Config::DEBUG_PROFILE {
return Err(Error::new(ErrorKind::InsecureSecretKey(profile.clone())));
} else {
} else if self.config.secret_key.is_zero() {
self.config.secret_key = crate::config::SecretKey::generate()
.unwrap_or(crate::config::SecretKey::zero());
warn!("secrets enabled without a configured `secret_key`");
warn!("secrets enabled without a stable `secret_key`");
info_!("disable `secrets` feature or configure a `secret_key`");
info_!("this becomes an {} in non-debug profiles", Paint::red("error"));