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.
15 lines
360 B
Rust
15 lines
360 B
Rust
use std::sync::Arc;
|
|
use std::fmt::Debug;
|
|
|
|
use async_trait::async_trait;
|
|
use mockall::automock;
|
|
|
|
use crate::ServiceError;
|
|
|
|
#[automock(type Context=();)]
|
|
#[async_trait]
|
|
pub trait UserService {
|
|
type Context: Clone + Debug + PartialEq + Eq + Send + Sync + 'static;
|
|
|
|
async fn current_user(&self, context: Self::Context) -> Result<Arc<str>, ServiceError>;
|
|
}
|