Skip to content

Commit

Permalink
bug: allow APNS env credentials to include serialized keys
Browse files Browse the repository at this point in the history
Closes #240
  • Loading branch information
jrconlin committed Nov 30, 2020
1 parent 9a88141 commit 72f8209
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
40 changes: 26 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion autoendpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ reqwest = "0.10.6"
rusoto_core = "0.45.0"
rusoto_dynamodb = "0.45.0"
# Using debug-logs avoids https://github.com/getsentry/sentry-rust/issues/237
sentry = { version = "0.21", features = ["debug-logs"] }
sentry = { version = "0.20", features = ["debug-logs"] }
serde = { version = "1.0", features = ["derive"] }
serde_dynamodb = "0.6"
serde_json = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions autoendpoint/src/routers/apns/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ impl ApnsRouter {
} else {
Endpoint::Production
};
let cert = if settings.cert.starts_with('/') {
let cert = if !settings.cert.starts_with('-') {
tokio::fs::read(settings.cert).await?
} else {
settings.cert.as_bytes().to_vec()
};
let key = if settings.key.starts_with('/') {
let key = if !settings.key.starts_with('-') {
tokio::fs::read(settings.key).await?
} else {
settings.key.as_bytes().to_vec()
Expand Down
1 change: 0 additions & 1 deletion autoendpoint/src/routers/apns/settings.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::HashMap;
use std::path::PathBuf;

/// Settings for `ApnsRouter`
#[derive(Clone, Debug, serde::Deserialize)]
Expand Down
4 changes: 3 additions & 1 deletion autoendpoint/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ impl Settings {
}

// Merge the environment overrides
config.merge(Environment::with_prefix(ENV_PREFIX))?;
// Note: Specify the separator here so that the shell can properly pass args
// down to the sub structures.
config.merge(Environment::with_prefix(ENV_PREFIX).separator("__"))?;

This comment has been minimized.

Copy link
@AzureMarker

AzureMarker Dec 1, 2020

Contributor

Is there an issue with the default separator of "."?
Example usage in https://github.com/mozilla-services/autopush-rs/blob/master/autoendpoint/docs/operation_notes.md


config.try_into::<Self>().map_err(|error| match error {
// Configuration errors are not very sysop friendly, Try to make them
Expand Down

0 comments on commit 72f8209

Please sign in to comment.