server: decode graphql parameter

This commit is contained in:
Valentin Tolmer 2023-04-10 18:32:31 +02:00 committed by nitnelave
parent 96f55ff28e
commit d18cf1ac37
3 changed files with 14 additions and 12 deletions

19
Cargo.lock generated
View File

@ -2404,7 +2404,8 @@ dependencies = [
"tracing-forest", "tracing-forest",
"tracing-log", "tracing-log",
"tracing-subscriber", "tracing-subscriber",
"uuid 0.8.2", "urlencoding",
"uuid 1.3.0",
"webpki-roots", "webpki-roots",
] ]
@ -2530,12 +2531,6 @@ dependencies = [
"digest 0.10.6", "digest 0.10.6",
] ]
[[package]]
name = "md5"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.5.0" version = "2.5.0"
@ -4399,14 +4394,17 @@ dependencies = [
"percent-encoding", "percent-encoding",
] ]
[[package]]
name = "urlencoding"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "0.8.2" version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
"md5",
]
[[package]] [[package]]
name = "uuid" name = "uuid"
@ -4415,6 +4413,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79" checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79"
dependencies = [ dependencies = [
"getrandom 0.2.8", "getrandom 0.2.8",
"md-5",
] ]
[[package]] [[package]]

View File

@ -32,7 +32,9 @@ ldap3_proto = ">=0.3.1"
log = "*" log = "*"
orion = "0.17" orion = "0.17"
rustls = "0.20" rustls = "0.20"
rustls-pemfile = "1"
serde = "*" serde = "*"
serde_bytes = "0.11"
serde_json = "1" serde_json = "1"
sha2 = "0.10" sha2 = "0.10"
thiserror = "*" thiserror = "*"
@ -44,8 +46,7 @@ tracing = "*"
tracing-actix-web = "0.7" tracing-actix-web = "0.7"
tracing-attributes = "^0.1.21" tracing-attributes = "^0.1.21"
tracing-log = "*" tracing-log = "*"
rustls-pemfile = "1" urlencoding = "2"
serde_bytes = "0.11"
webpki-roots = "*" webpki-roots = "*"
[dependencies.chrono] [dependencies.chrono]

View File

@ -124,10 +124,12 @@ impl<Handler: BackendHandler> Query<Handler> {
} }
pub async fn user(context: &Context<Handler>, user_id: String) -> FieldResult<User<Handler>> { pub async fn user(context: &Context<Handler>, user_id: String) -> FieldResult<User<Handler>> {
use anyhow::Context;
let span = debug_span!("[GraphQL query] user"); let span = debug_span!("[GraphQL query] user");
span.in_scope(|| { span.in_scope(|| {
debug!(?user_id); debug!(?user_id);
}); });
let user_id = urlencoding::decode(&user_id).context("Invalid user parameter")?;
let user_id = UserId::new(&user_id); let user_id = UserId::new(&user_id);
let handler = context let handler = context
.get_readable_handler(&user_id) .get_readable_handler(&user_id)