potree_auth/authentication/ports/
authentication_engine.rs1use std::fmt::Debug;
2
3use async_trait::async_trait;
4
5use super::super::domain::AuthorizeData;
6use super::super::domain::CallbackRequestParams;
7use super::super::domain::OidcSessionPersisted;
8use crate::user::domain::User;
9
10#[async_trait]
13#[cfg_attr(test, mockall::automock)]
14pub trait AuthenticationEngine: Debug + Send + Sync + 'static {
15 async fn authorize(&self) -> Result<AuthorizeData, AuthenticationEngineError>;
19
20 async fn callback(
29 &self,
30 callback_params: CallbackRequestParams,
31 persisted_data: OidcSessionPersisted,
32 ) -> Result<User, AuthenticationEngineError>;
33}
34
35#[derive(Debug, Clone, thiserror::Error)]
36pub enum AuthenticationEngineError {
37 #[error("unable to set up infrastructure: {message}")]
38 Infrastructure { message: String },
39
40 #[error("unable exchange information with the IdP: {message}")]
41 IdpExchange { message: String },
42
43 #[error("unable to validate IdP data: {message}")]
44 Validation { message: String },
45}