about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2024-08-01 20:29:26 +0300
committerVika <vika@fireburn.ru>2024-08-01 20:40:32 +0300
commit46e7938121929a4c5f4d15a295e74d8685b17b2b (patch)
tree8c3c5844a4a571b939af94577d6e758b91f3209b /src
parent3c4eb66ca5f96b8cc3289aba6c34373df1dba64a (diff)
downloadkittybox-46e7938121929a4c5f4d15a295e74d8685b17b2b.tar.zst
Get cookie key from the environment
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();