Skip to main content

potree_auth/authentication/adapters/authentication_engine/
no_op.rs

1use async_trait::async_trait;
2
3use super::super::super::domain::AuthorizeData;
4use super::super::super::domain::CallbackRequestParams;
5use super::super::super::domain::OidcSessionPersisted;
6use super::super::super::ports::authentication_engine::AuthenticationEngine;
7use crate::authentication::ports::authentication_engine::AuthenticationEngineError;
8use crate::user::domain::User;
9
10/// A blank authentication service. Would be used if the application does not
11/// require authentication.
12#[derive(Debug, Clone)]
13pub struct NoOpAuthenticationEngine;
14
15#[async_trait]
16impl AuthenticationEngine for NoOpAuthenticationEngine {
17    #[tracing::instrument]
18    async fn authorize(&self) -> Result<AuthorizeData, AuthenticationEngineError> {
19        Err(AuthenticationEngineError::Infrastructure {
20            message:
21                "this is a placeholder for when the application does not require authentication"
22                    .to_owned(),
23        })
24    }
25
26    #[tracing::instrument]
27    async fn callback(
28        &self,
29        _callback_params: CallbackRequestParams,
30        _persisted_data: OidcSessionPersisted,
31    ) -> Result<User, AuthenticationEngineError> {
32        Err(AuthenticationEngineError::Infrastructure {
33            message:
34                "this is a placeholder for when the application does not require authentication"
35                    .to_owned(),
36        })
37    }
38}