mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 07:02:24 +00:00
auth: Add tracing around token validation
This commit is contained in:
@@ -10,6 +10,7 @@ use std::{
|
|||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
use tracing::{info_span, Instrument};
|
||||||
|
|
||||||
pub struct AuthenticationMiddleware<AP: AuthenticationProvider> {
|
pub struct AuthenticationMiddleware<AP: AuthenticationProvider> {
|
||||||
auth_provider: Arc<AP>,
|
auth_provider: Arc<AP>,
|
||||||
@@ -67,8 +68,10 @@ where
|
|||||||
if let Ok(auth) = Authorization::<Basic>::parse(req.request()) {
|
if let Ok(auth) = Authorization::<Basic>::parse(req.request()) {
|
||||||
let user_id = auth.as_ref().user_id();
|
let user_id = auth.as_ref().user_id();
|
||||||
if let Some(password) = auth.as_ref().password() {
|
if let Some(password) = auth.as_ref().password() {
|
||||||
if let Ok(Some(user)) =
|
if let Ok(Some(user)) = auth_provider
|
||||||
auth_provider.validate_user_token(user_id, password).await
|
.validate_user_token(user_id, password)
|
||||||
|
.instrument(info_span!("validate_user_token"))
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
req.extensions_mut().insert(user);
|
req.extensions_mut().insert(user);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user