1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-07-22 17:18:35 +00:00

use sha2 of the key instead of the key directly

This commit is contained in:
Shady Khalifa 2023-04-24 22:42:10 +02:00
parent 933cd8a068
commit 37952c1a19
No known key found for this signature in database
GPG key ID: 52DFAC81BEA54EAA
3 changed files with 11 additions and 1 deletions

1
Cargo.lock generated
View file

@ -415,6 +415,7 @@ dependencies = [
"serde_json",
"serde_yaml",
"sha-1",
"sha2",
"thiserror",
"thread_local",
"threadpool",

View file

@ -88,6 +88,7 @@ thread_local = "1.1.3"
# used for TURN server authentication
hmac = "0.12.1"
sha-1 = "0.10.0"
sha2 = "0.9"
# used for conduit's CLI and admin room command parsing
clap = { version = "4.0.11", default-features = false, features = ["std", "derive", "help", "usage", "error-context"] }
futures-util = { version = "0.3.17", default-features = false }

View file

@ -229,6 +229,8 @@ impl Service {
mod tests {
use std::path::PathBuf;
use sha2::Digest;
use super::*;
struct MockedKVDatabase;
@ -298,7 +300,13 @@ mod tests {
let mut r = PathBuf::new();
r.push("/tmp");
r.push("media");
r.push(base64::encode_config(key, base64::URL_SAFE_NO_PAD));
// r.push(base64::encode_config(key, base64::URL_SAFE_NO_PAD));
// use the sha256 hash of the key as the file name instead of the key itself
// this is because the base64 encoded key can be longer than 255 characters.
r.push(base64::encode_config(
sha2::Sha256::digest(&key),
base64::URL_SAFE_NO_PAD,
));
// Check that the file path is not longer than 255 characters
// (255 is the maximum length of a file path on most file systems)
assert!(