You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/env.rs
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ use std::{env, path::PathBuf};
5
5
use api_framework::{parse_env, static_lazy_lock};
6
6
use tracing::level_filters::LevelFilter;
7
7
8
+
usecrate::sha256::sha256_hex_to_bytes;
9
+
8
10
/// Sets up environment variables from `.env` and `{crate_name}.env`.
9
11
pubfnsetup(){
10
12
dotenvy::dotenv().ok();
@@ -61,10 +63,10 @@ static_lazy_lock! {
61
63
62
64
static_lazy_lock!{
63
65
/// The PASETO symmetric key hashed using SHA256.
64
-
pubPASETO_SYMMETRIC_KEY:[u8;32] = parse_env!("PASETO_SYMMETRIC_KEY" => |k| Ok::<[u8;32], _>(k.as_bytes().try_into().expect("PASETO_SYMMETRIC_KEY must be 32 bytes long"))).expect("PASETO_SYMMETRIC_KEY not set in environment");
66
+
pubPASETO_SYMMETRIC_KEY:[u8;32] = parse_env!("PASETO_SYMMETRIC_KEY" => |k| Ok(sha256_hex_to_bytes(&k).expect("PASETO_SYMMETRIC_KEY must be a valid 32-byte long SHA256 token"))).expect("PASETO_SYMMETRIC_KEY not set in environment");
65
67
}
66
68
67
69
static_lazy_lock!{
68
70
/// The session symmetric key hashed using SHA256.
69
-
pubSESSION_SYMMETRIC_KEY:[u8;32] = parse_env!("SESSION_SYMMETRIC_KEY" => |k| Ok::<[u8;32], _>(k.as_bytes().try_into().expect("SESSION_SYMMETRIC_KEY must be 32 bytes long"))).expect("SESSION_SYMMETRIC_KEY not set in environment");
71
+
pubSESSION_SYMMETRIC_KEY:[u8;32] = parse_env!("SESSION_SYMMETRIC_KEY" => |k| Ok(sha256_hex_to_bytes(&k).expect("SESSION_SYMMETRIC_KEY must be a valid 32-byte long SHA256 token"))).expect("SESSION_SYMMETRIC_KEY not set in environment");
0 commit comments