Browse Source

Merge branch 'jwt-token-fixed-2' into 'jwt-token-fixed'

Add support of 'JWT_SECRET' environment variable

See merge request famedly/conduit!22
merge-requests/22/merge
andor0 5 years ago
parent
commit
4e9402c73a
  1. 10
      src/database/globals.rs

10
src/database/globals.rs

@ -54,8 +54,12 @@ impl Globals<'_> {
} }
}; };
let jwt_decoding_key = let jwt_decoding_key = config
config.get_str("jwt_secret").map(|secret| jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()).into_static()).ok(); .get_str("jwt_secret")
.map(ToString::to_string)
.or(std::env::var("JWT_SECRET"))
.map(|secret| jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()).into_static())
.ok();
Ok(Self { Ok(Self {
globals, globals,
@ -63,7 +67,7 @@ impl Globals<'_> {
reqwest_client: reqwest::Client::new(), reqwest_client: reqwest::Client::new(),
server_name: config server_name: config
.get_str("server_name") .get_str("server_name")
.map(std::string::ToString::to_string) .map(ToString::to_string)
.unwrap_or_else(|_| { .unwrap_or_else(|_| {
std::env::var("SERVER_NAME").unwrap_or_else(|_| "localhost".to_string()) std::env::var("SERVER_NAME").unwrap_or_else(|_| "localhost".to_string())
}) })

Loading…
Cancel
Save