manta_server/backend_dispatcher/
authentication.rs

1//! `AuthenticationTrait` impl for `StaticBackendDispatcher`.
2//!
3//! Wraps the dispatch with structured tracing so an auth failure
4//! surfaces backend + user metadata at the dispatcher boundary.
5
6use super::*;
7
8impl AuthenticationTrait for StaticBackendDispatcher {
9  async fn get_api_token(
10    &self,
11    username: &str,
12    password: &str,
13  ) -> Result<String, Error> {
14    let backend = self.backend_kind();
15    tracing::debug!(backend, user = %username, "dispatch: get_api_token");
16    let result = dispatch!(self, get_api_token, username, password);
17    if let Err(ref e) = result {
18      tracing::warn!(
19        backend,
20        user = %username,
21        error = %e,
22        "dispatch: get_api_token returned error from backend client"
23      );
24    }
25    result
26  }
27
28  async fn validate_api_token(&self, auth_token: &str) -> Result<(), Error> {
29    let backend = self.backend_kind();
30    tracing::debug!(backend, "dispatch: validate_api_token");
31    let result = dispatch!(self, validate_api_token, auth_token);
32    if let Err(ref e) = result {
33      tracing::warn!(
34        backend,
35        error = %e,
36        "dispatch: validate_api_token returned error from backend client"
37      );
38    }
39    result
40  }
41}