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:
parent
933cd8a068
commit
37952c1a19
3 changed files with 11 additions and 1 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -415,6 +415,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml",
|
||||||
"sha-1",
|
"sha-1",
|
||||||
|
"sha2",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"thread_local",
|
"thread_local",
|
||||||
"threadpool",
|
"threadpool",
|
||||||
|
|
|
@ -88,6 +88,7 @@ thread_local = "1.1.3"
|
||||||
# used for TURN server authentication
|
# used for TURN server authentication
|
||||||
hmac = "0.12.1"
|
hmac = "0.12.1"
|
||||||
sha-1 = "0.10.0"
|
sha-1 = "0.10.0"
|
||||||
|
sha2 = "0.9"
|
||||||
# used for conduit's CLI and admin room command parsing
|
# 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"] }
|
clap = { version = "4.0.11", default-features = false, features = ["std", "derive", "help", "usage", "error-context"] }
|
||||||
futures-util = { version = "0.3.17", default-features = false }
|
futures-util = { version = "0.3.17", default-features = false }
|
||||||
|
|
|
@ -229,6 +229,8 @@ impl Service {
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use sha2::Digest;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
struct MockedKVDatabase;
|
struct MockedKVDatabase;
|
||||||
|
@ -298,7 +300,13 @@ mod tests {
|
||||||
let mut r = PathBuf::new();
|
let mut r = PathBuf::new();
|
||||||
r.push("/tmp");
|
r.push("/tmp");
|
||||||
r.push("media");
|
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
|
// Check that the file path is not longer than 255 characters
|
||||||
// (255 is the maximum length of a file path on most file systems)
|
// (255 is the maximum length of a file path on most file systems)
|
||||||
assert!(
|
assert!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue