Skip to content

Commit

Permalink
Merge pull request #12 from mozilla-services/fix/11
Browse files Browse the repository at this point in the history
fix: match python autopush's crypto_key format
  • Loading branch information
bbangert authored Jun 21, 2018
2 parents 92ca8e7 + 0eeabcb commit b67c0d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN \
useradd --uid 10001 --gid 10001 --home /app --create-home app && \
\
apt-get -qq update && \
apt-get -qq install -y libssl-dev && \
apt-get -qq install -y libssl-dev ca-certificates && \
rm -rf /var/lib/apt/lists

COPY --from=builder /app/bin /app/bin
Expand Down
11 changes: 8 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,18 @@ pub struct ServerOptions {

impl ServerOptions {
pub fn from_settings(settings: Settings) -> Result<Self> {
let fernets: Vec<Fernet> = settings
.crypto_key
let crypto_key = &settings.crypto_key;
if !(crypto_key.starts_with("[") && crypto_key.ends_with("]")) {
return Err("Invalid AUTOPUSH_CRYPTO_KEY".into());
}
let crypto_key = &crypto_key[1..crypto_key.len() - 1];
let fernets: Vec<Fernet> = crypto_key
.split(',')
.map(|s| s.trim().to_string())
.map(|key| Fernet::new(&key).expect("Invalid key supplied"))
.map(|key| Fernet::new(&key).expect("Invalid AUTOPUSH_CRYPTO_KEY"))
.collect();
let fernet = MultiFernet::new(fernets);

let ddb = DynamoStorage::new();
let message_table_names = ddb
.list_message_tables(&settings.message_tablename)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def setup_module():
statsd_host="",
router_tablename=ROUTER_TABLE,
message_tablename=MESSAGE_TABLE,
crypto_key=CRYPTO_KEY,
crypto_key="[{}]".format(CRYPTO_KEY),
auto_ping_interval=60.0,
auto_ping_timeout=10.0,
close_handshake_timeout=5,
Expand Down

0 comments on commit b67c0d6

Please sign in to comment.