mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-06-11 10:53:19 +02:00
Output plentiful trace info for API calls
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use capnp::capability::Promise;
|
||||
use capnp::Error;
|
||||
use capnp_rpc::pry;
|
||||
use rsasl::mechname::Mechname;
|
||||
use rsasl::property::AuthId;
|
||||
use rsasl::session::{Session, Step};
|
||||
use std::fmt;
|
||||
@ -23,8 +24,18 @@ pub struct Authentication {
|
||||
}
|
||||
|
||||
impl Authentication {
|
||||
pub fn new(session: Session, sessionmanager: SessionManager) -> Self {
|
||||
let span = tracing::info_span!(target: TARGET, "Authentication",);
|
||||
pub fn new(
|
||||
parent: &Span,
|
||||
mechanism: &Mechname, /* TODO: this is stored in session as well, get it out of there. */
|
||||
session: Session,
|
||||
sessionmanager: SessionManager,
|
||||
) -> Self {
|
||||
let span = tracing::info_span!(
|
||||
target: TARGET,
|
||||
parent: parent,
|
||||
"Authentication",
|
||||
mechanism = mechanism.as_str()
|
||||
);
|
||||
tracing::trace!(
|
||||
target: TARGET,
|
||||
parent: &span,
|
||||
@ -121,7 +132,7 @@ impl AuthenticationSystem for Authentication {
|
||||
"Authentication didn't provide an authid as required".to_string(),
|
||||
)
|
||||
}));
|
||||
let session = pry!(manager.open(uid.as_ref()).ok_or_else(|| {
|
||||
let session = pry!(manager.open(&self.span, uid.as_ref()).ok_or_else(|| {
|
||||
tracing::warn!(uid = uid.as_str(), "Failed to lookup the given user");
|
||||
capnp::Error::failed("Failed to lookup the given user".to_string())
|
||||
}));
|
||||
|
@ -90,7 +90,7 @@ impl bootstrap::Server for BootCap {
|
||||
"mechanisms",
|
||||
)
|
||||
.entered();
|
||||
tracing::trace!("method call");
|
||||
tracing::trace!(target: "bffh::api", "method call");
|
||||
|
||||
let builder = result.get();
|
||||
let mechs: Vec<_> = self
|
||||
@ -149,7 +149,7 @@ impl bootstrap::Server for BootCap {
|
||||
let mechname = Mechname::new(mechanism.as_bytes());
|
||||
let auth = if let Ok(mechname) = mechname {
|
||||
if let Ok(session) = self.authentication.start(mechname) {
|
||||
Authentication::new(session, self.sessionmanager.clone())
|
||||
Authentication::new(&self.span, mechname, session, self.sessionmanager.clone())
|
||||
} else {
|
||||
Authentication::invalid_mechanism()
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl APIServer {
|
||||
|
||||
let connection_span = tracing::info_span!(
|
||||
target: "bffh::api",
|
||||
"Bootstrap",
|
||||
"connection",
|
||||
%peer.ip,
|
||||
peer.port,
|
||||
);
|
||||
|
Reference in New Issue
Block a user