about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs11
3 files changed, 12 insertions, 1 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 7306b8fdaeeb..4f64a7026b33 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -267,6 +267,7 @@ dependencies = [
  "hyper 0.11.25 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "r2d2 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "reqwest 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/Cargo.toml b/Cargo.toml
index 66babe416737..2fb52937fdec 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,3 +22,4 @@ reqwest = "0.8"
 frank_jwt = "3.0"
 serde_json = "1.0"
 hyper = "*"
+rand = "0.4"
diff --git a/src/main.rs b/src/main.rs
index 2e2664a2cfe9..a68721729ac2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -19,6 +19,7 @@ extern crate chrono;
 extern crate env_logger;
 extern crate futures;
 extern crate r2d2;
+extern crate rand;
 extern crate reqwest;
 extern crate serde;
 extern crate url;
@@ -41,6 +42,7 @@ use db::*;
 use diesel::pg::PgConnection;
 use diesel::r2d2::{ConnectionManager, Pool};
 use std::env;
+use rand::{OsRng, Rng};
 use handlers::*;
 
 fn config(name: &str) -> String {
@@ -81,7 +83,14 @@ fn main() {
 
     info!("Initialising HTTP server ...");
     let bind_host = config_default("CONVERSE_BIND_HOST", "127.0.0.1:4567");
-    let key: &[u8] = &[0; 32]; // TODO: generate!
+    let key = {
+        let mut key_bytes = [0; 32];
+        let mut rng = OsRng::new()
+            .expect("Failed to retrieve RNG for key generation");
+        rng.fill_bytes(&mut key_bytes);
+
+        key_bytes
+    };
 
     server::new(move || {
         let template_path = concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*");