Skip to content

Commit 16959a9

Browse files
christian-schillingLMG
authored andcommitted
Add extra tracing to check_auth
To help with diagnosing auth problems via traces. Change-Id: auth-tracing
1 parent 030ad93 commit 16959a9

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

josh-proxy/src/auth.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,26 @@ pub async fn check_auth(url: &str, auth: &Handle, required: bool) -> josh::JoshR
9696
let r = builder.body(hyper::Body::empty())?;
9797
let resp = client.request(r).await?;
9898

99-
if resp.status() == 200 {
99+
let status = resp.status();
100+
101+
tracing::trace!("http resp.status {:?}", resp.status());
102+
103+
let msg = format!("got http response: {} {:?}", nurl, resp);
104+
105+
if status == 200 {
100106
AUTH_TIMERS
101107
.lock()?
102108
.insert((url.to_string(), auth.clone()), std::time::Instant::now());
103109
Ok(true)
104-
} else if resp.status() == 401 {
110+
} else if status == 401 {
111+
tracing::warn!("resp.status == 401: {:?}", &msg);
112+
tracing::trace!(
113+
"body: {:?}",
114+
std::str::from_utf8(&hyper::body::to_bytes(resp.into_body()).await?)
115+
);
105116
Ok(false)
106117
} else {
107-
return Err(josh::josh_error(&format!(
108-
"got http response: {} {:?}",
109-
nurl, resp
110-
)));
118+
return Err(josh::josh_error(&msg));
111119
}
112120
}
113121

0 commit comments

Comments
 (0)