refactor(api): ensure trace are for all HTTP req.

- ensure Nextcloud handler has also traces
    - ensure that user_id is provisionned by the nextcloud auth method
This commit is contained in:
Edouard Vanbelle
2026-06-06 11:54:23 +02:00
parent e4bb5b064a
commit 04a4868cd2
2 changed files with 50 additions and 21 deletions
@@ -114,6 +114,15 @@ pub async fn basic_auth_middleware(
);
return Err(NextcloudAuthError::Unauthorized);
}
// Populate the deferred `user_id` field on the request
// tracing span (declared in `middleware/trace_span.rs::ClientIpMakeSpan`).
// Mirrors what `interfaces/middleware/auth.rs` does for the
// JWT path so the two auth surfaces produce log lines with
// the same structured shape — without this, every NC
// request would appear in the logs with `user_id=-`,
// making it harder to correlate WebDAV / OCS activity to
// a specific principal.
tracing::Span::current().record("user_id", user_id.to_string());
request.extensions_mut().insert(Arc::new(CurrentUser {
id: user_id,
username: uname,