diff options
author | metamuffin <metamuffin@disroot.org> | 2023-08-01 20:32:35 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-08-01 20:32:35 +0200 |
commit | ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b (patch) | |
tree | fc8c7ad11ca2dfc7ebccb65ea9ea3c27827405dd /server/src/routes/ui/account/session | |
parent | f7992589cf45c699599a7ee5fc4634c9db16ff87 (diff) | |
download | jellything-ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b.tar jellything-ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b.tar.bz2 jellything-ff9060ea0987e29e4d468ff7c9fed7cc7109bf2b.tar.zst |
federation possible but inconvinient
Diffstat (limited to 'server/src/routes/ui/account/session')
-rw-r--r-- | server/src/routes/ui/account/session/token.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/server/src/routes/ui/account/session/token.rs b/server/src/routes/ui/account/session/token.rs index d4546aa..f82b475 100644 --- a/server/src/routes/ui/account/session/token.rs +++ b/server/src/routes/ui/account/session/token.rs @@ -24,17 +24,16 @@ pub fn create(username: String, expire: Duration) -> String { let cipher = aes_gcm_siv::Aes256GcmSiv::new_from_slice(&*SESSION_KEY).unwrap(); let nonce = [(); 12].map(|_| rand::random()); - eprintln!("SESSION_KEY={SESSION_KEY:?}"); let mut ciphertext = cipher .encrypt(&GenericArray::from(nonce), plaintext.as_slice()) .unwrap(); ciphertext.extend(nonce); - base64::engine::general_purpose::STANDARD.encode(&ciphertext) + base64::engine::general_purpose::URL_SAFE.encode(&ciphertext) } pub fn validate(token: &str) -> anyhow::Result<String> { - let ciphertext = base64::engine::general_purpose::STANDARD.decode(token)?; + let ciphertext = base64::engine::general_purpose::URL_SAFE.decode(token)?; let cipher = aes_gcm_siv::Aes256GcmSiv::new_from_slice(&*SESSION_KEY).unwrap(); let (ciphertext, nonce) = ciphertext.split_at(ciphertext.len() - 12); let plaintext = cipher |