From 46e7938121929a4c5f4d15a295e74d8685b17b2b Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 1 Aug 2024 20:29:26 +0300 Subject: Get cookie key from the environment --- src/main.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') 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>> = Default::default(); -- cgit 1.4.1