Skip to content

Commit 5d8b2db

Browse files
author
Nicolas Pernoud
committed
chore: refactored dav_file to use async file traits
1 parent d85ea62 commit 5d8b2db

File tree

12 files changed

+821
-655
lines changed

12 files changed

+821
-655
lines changed

backend/Cargo.toml

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ argon2 = { features = ["alloc", "password-hash"], default-features = false, vers
1616
async_zip = { features = ["deflate", "tokio"], default-features = false, version = "0.0.18" }
1717
async-stream = "0.3.6"
1818
async-walkdir = "2.1.0"
19-
aws-lc-rs = { version = "1.13.3", default-features = false, features = ["bindgen"] }
20-
axum = { version = "0.8.4", features = ["http2", "json", "query", "tokio"], default-features = false }
21-
axum-extra = { version = "0.10.1", features = ["cookie-private", "typed-header"], default-features = false }
19+
aws-lc-rs = { version = "1.14.1", default-features = false, features = ["bindgen"] }
20+
axum = { version = "0.8.6", features = ["http2", "json", "query", "tokio"], default-features = false }
21+
axum-extra = { version = "0.10.3", features = ["cookie-private", "typed-header"], default-features = false }
2222
axum-server = { version = "0.7.2", default-features = false, features = ["tls-rustls"] }
2323
base64ct = { version = "1.8.0", features = ["alloc"] }
2424
chacha20poly1305 = { version = "0.10.1", features = ["stream"], default-features = false }
25-
chrono = { default-features = false, version = "0.4.41" }
25+
chrono = { default-features = false, version = "0.4.42" }
2626
filetime = "0.2.26"
2727
futures = { default-features = false, version = "0.3.31" }
2828
futures-util = { default-features = false, version = "0.3.31" }
@@ -32,24 +32,24 @@ http-body-util = "0.1.3"
3232
hyper = { version = "1.7.0", default-features = false }
3333
hyper-hickory = { version = "0.8.0", default-features = false, features = ["system-config", "tokio"] }
3434
hyper-rustls = { version = "0.27.7", features = ["aws-lc-rs", "http1", "http2", "tls12", "webpki-tokio"], default-features = false }
35-
hyper-util = { version = "0.1.16", features = ["client-legacy", "http1", "tokio"], default-features = false }
36-
jsonwebtoken-aws-lc = { version = "9.3.0", default-features = false }
35+
hyper-util = { version = "0.1.17", features = ["client-legacy", "http1", "tokio"], default-features = false }
36+
jsonwebtoken = { version = "10", features = ["aws_lc_rs"], default-features = false }
3737
maxminddb = "0.26.0"
3838
mime_guess = { default-features = false, version = "2.0.5" }
3939
oauth2 = { version = "5.0.0", default-features = false }
4040
percent-encoding = { default-features = false, version = "2.3.2" }
4141
quick-xml = "0.38.3"
4242
rand = { default-features = false, version = "0.9.2", features = ["os_rng"] }
43-
rcgen = { version = "0.14.3", default-features = false, optional = true, features = ["aws_lc_rs", "crypto", "pem"] }
44-
rustls = { default-features = false, version = "0.23.31", features = ["aws_lc_rs"] }
45-
rustls-acme = { version = "0.14.0", features = ["aws-lc-rs", "axum", "webpki-roots"], default-features = false }
43+
rcgen = { version = "0.14.5", default-features = false, optional = true, features = ["aws_lc_rs", "crypto", "pem"] }
44+
rustls = { default-features = false, version = "0.23.32", features = ["aws_lc_rs"] }
45+
rustls-acme = { version = "0.14.1", features = ["aws-lc-rs", "axum", "webpki-roots"], default-features = false }
4646
rustls-pki-types = { version = "1.12.0" }
47-
serde = { version = "1.0.219", default-features = false }
48-
serde_json = { default-features = false, version = "1.0.143" }
47+
serde = { version = "1.0.228", default-features = false }
48+
serde_json = { default-features = false, version = "1.0.145" }
4949
serde_yaml_ng = "0.10.0"
5050
sha2 = { default-features = false, version = "0.10.9" }
51-
sysinfo = { default-features = false, version = "0.37.0", features = ["disk", "system"] }
52-
time = { default-features = false, version = "0.3.41" }
51+
sysinfo = { default-features = false, version = "0.37.2", features = ["disk", "system"] }
52+
time = { default-features = false, version = "0.3.44" }
5353
tokio = { version = "1.47.1", features = ["full"], default-features = false }
5454
tokio-stream = { version = "0.1.17", default-features = false }
5555
tokio-util = { version = "0.7.16", default-features = false }
@@ -58,10 +58,10 @@ tower-http = { version = "0.6.6", features = ["fs"], default-features = false }
5858
tower-service = "0.3.3"
5959
tracing = { default-features = false, version = "0.1.41", features = ["attributes"] }
6060
tracing-appender = "0.2.3"
61-
tracing-subscriber = { version = "0.3.19", features = ["ansi", "env-filter", "local-time"], default-features = false }
61+
tracing-subscriber = { version = "0.3.20", features = ["ansi", "env-filter", "local-time"], default-features = false }
6262
trim-in-place = "0.1.7"
6363
urlencoding = "2.1.3"
64-
uuid = { version = "1.18.0", features = ["fast-rng", "v4"], default-features = false }
64+
uuid = { version = "1.18.1", features = ["fast-rng", "v4"], default-features = false }
6565

6666
[features]
6767
default = ["self_signed"]
@@ -70,6 +70,7 @@ self_signed = ["dep:rcgen"]
7070
[dev-dependencies]
7171
async-tungstenite = { version = "0.31.0", features = ["tokio-runtime"] }
7272
reqwest = { version = "0.12.23", default-features = false, features = ["cookies", "json", "native-tls", "stream"] }
73+
tempfile = "3.23.0"
7374
tungstenite = "0.27.0"
7475

7576
[profile.release_optimized]

backend/src/apps/mod.rs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -194,43 +194,43 @@ where
194194
.await?;
195195

196196
// If the response contains a location, alter the redirect location if the redirection is relative to the proxied host
197-
if let Some(location) = response.headers().get("location") {
198-
if let Ok(location) = location.to_str() {
199-
// parse location as an url
200-
let location_uri: Uri = match location.trim_start_matches('.').parse() {
201-
Ok(uri) => uri,
202-
Err(_) => {
203-
// Try to add a forward slash
204-
match format!("/{location}").parse() {
205-
Ok(uri) => uri,
206-
Err(e) => {
207-
error!(
208-
"proxy redirect location header parsing for {:?} gave error: {:?}",
209-
location, e
210-
);
211-
return Err(<ProxyError as Into<axum::response::Response>>::into(
212-
ProxyError::BadRedirectResponseError,
213-
));
214-
}
197+
if let Some(location) = response.headers().get("location")
198+
&& let Ok(location) = location.to_str()
199+
{
200+
// parse location as an url
201+
let location_uri: Uri = match location.trim_start_matches('.').parse() {
202+
Ok(uri) => uri,
203+
Err(_) => {
204+
// Try to add a forward slash
205+
match format!("/{location}").parse() {
206+
Ok(uri) => uri,
207+
Err(e) => {
208+
error!(
209+
"proxy redirect location header parsing for {:?} gave error: {:?}",
210+
location, e
211+
);
212+
return Err(<ProxyError as Into<axum::response::Response>>::into(
213+
ProxyError::BadRedirectResponseError,
214+
));
215215
}
216216
}
217-
};
218-
// test if the host of this url contains the target service host
219-
if location_uri
220-
.host()
221-
.is_some_and(|h| h.contains(app.forward_authority.host()))
217+
}
218+
};
219+
// test if the host of this url contains the target service host
220+
if location_uri
221+
.host()
222+
.is_some_and(|h| h.contains(app.forward_authority.host()))
223+
{
224+
// if so, replace the target service host with the front service host
225+
let mut parts = location_uri.into_parts();
226+
parts.scheme = Some(app.app_scheme);
227+
if let Ok(authority) = hostname.parse::<Authority>() {
228+
parts.authority = Some(authority);
229+
}
230+
if let Ok(uri) = Uri::from_parts(parts)
231+
&& let Ok(uri) = HeaderValue::from_str(&uri.to_string())
222232
{
223-
// if so, replace the target service host with the front service host
224-
let mut parts = location_uri.into_parts();
225-
parts.scheme = Some(app.app_scheme);
226-
if let Ok(authority) = hostname.parse::<Authority>() {
227-
parts.authority = Some(authority);
228-
}
229-
if let Ok(uri) = Uri::from_parts(parts)
230-
&& let Ok(uri) = HeaderValue::from_str(&uri.to_string())
231-
{
232-
response.headers_mut().insert(LOCATION, uri);
233-
}
233+
response.headers_mut().insert(LOCATION, uri);
234234
}
235235
}
236236
}

backend/src/configuration.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,11 @@ where
366366
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
367367
let configmap = ConfigMap::from_ref(state);
368368

369-
let host = axum_extra::extract::Host::from_request_parts(parts, state)
370-
.await
371-
.map_err(|_| StatusCode::NOT_FOUND)?;
369+
let host = <axum_extra::extract::Host as FromRequestParts<S>>::from_request_parts(
370+
parts, state,
371+
)
372+
.await
373+
.map_err(|_| StatusCode::NOT_FOUND)?;
372374

373375
let hostname = host.0.split_once(':').unwrap_or((&host.0, "")).0;
374376

0 commit comments

Comments
 (0)