summaryrefslogtreecommitdiffstats
path: root/rust/src/lib.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-12-31 17:40:51 -0800
committerBryan Newbold <bnewbold@robocracy.org>2018-12-31 17:40:51 -0800
commitb930bf22d4974363934514919539149a69b15167 (patch)
treea8ff4edf1e0e7a8d680bd82f4416c9fda8282440 /rust/src/lib.rs
parente661263baab5ff791986aaa6cc5d4996b149d4ce (diff)
downloadfatcat-b930bf22d4974363934514919539149a69b15167.tar.gz
fatcat-b930bf22d4974363934514919539149a69b15167.zip
allow multiple 'alt' keys to be specified in env
Diffstat (limited to 'rust/src/lib.rs')
-rw-r--r--rust/src/lib.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index a31404da..7d00641a 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -122,7 +122,24 @@ pub fn env_confectionary() -> Result<AuthConfectionary> {
let auth_location = env::var("AUTH_LOCATION").expect("AUTH_LOCATION must be set");
let auth_key = env::var("AUTH_SECRET_KEY").expect("AUTH_SECRET_KEY must be set");
let auth_key_ident = env::var("AUTH_KEY_IDENT").expect("AUTH_KEY_IDENT must be set");
- AuthConfectionary::new(auth_location, auth_key_ident, auth_key)
+ info!("Loaded primary auth key: {}", auth_key_ident);
+ let mut confectionary = AuthConfectionary::new(auth_location, auth_key_ident, auth_key)?;
+ match env::var("AUTH_ALT_KEYS") {
+ Ok(var) => {
+ for pair in var.split(",") {
+ let pair: Vec<&str> = pair.split(":").collect();
+ if pair.len() != 2 {
+ println!("{:#?}", pair);
+ bail!("couldn't parse keypair from AUTH_ALT_KEYS (expected 'ident:key' pairs separated by commas)");
+ }
+ info!("Loading alt auth key: {}", pair[0]);
+ confectionary.add_keypair(pair[0].to_string(), pair[1].to_string())?;
+
+ }
+ },
+ Err(_) => (),
+ }
+ Ok(confectionary)
}
/// Instantiate a new API server with a pooled database connection