Wrap Context with Autentication enum

Context should contain information which is required to get
the information if the service call is authenticated.  Context
could be the username for example.  But services call other
services internally and for this, authentication must not be
checked.  In this case, they can now pass Authentication::Full
which always successfully authenticates.
This commit is contained in:
Simon Goller 2024-05-09 14:58:19 +02:00
parent bf94ec33de
commit b0000c0117
18 changed files with 252 additions and 217 deletions

View file

@ -1,4 +1,5 @@
use std::sync::Arc;
use std::fmt::Debug;
use async_trait::async_trait;
use mockall::automock;
@ -8,7 +9,7 @@ use crate::ServiceError;
#[automock(type Context=();)]
#[async_trait]
pub trait UserService {
type Context: Clone + Send + Sync + 'static;
type Context: Clone + Debug + PartialEq + Eq + Send + Sync + 'static;
async fn current_user(&self, context: Self::Context) -> Result<Arc<str>, ServiceError>;
}