about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs
index 788e765..4af8a81 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,4 @@
+use base64::Engine;
 use kittybox::{database::Storage, indieauth::backend::AuthBackend, media::storage::MediaStore, webmentions::Webmention, compose_kittybox};
 use tokio::{sync::Mutex, task::JoinSet};
 use std::{env, time::Duration, sync::Arc};
@@ -79,7 +80,13 @@ async fn main() {
         });
 
     // TODO: load from environment
-    let cookie_key = axum_extra::extract::cookie::Key::generate();
+    let cookie_key = axum_extra::extract::cookie::Key::from(&env::var("COOKIE_KEY")
+        .as_deref()
+        .map(|s| base64::prelude::BASE64_STANDARD.decode(s.as_bytes())
+            .expect("Invalid cookie key: must be base64 encoded")
+        )
+        .unwrap()
+    );
 
     let cancellation_token = tokio_util::sync::CancellationToken::new();
     let jobset: Arc<Mutex<JoinSet<()>>> = Default::default();