potree_auth/authentication/application/
service.rs1use std::sync::Arc;
2
3use super::super::domain::AuthorizeData;
4use super::super::domain::CallbackRequestParams;
5use super::super::domain::OidcSessionPersisted;
6use super::super::ports::authentication_engine::AuthenticationEngine;
7use super::error::AuthenticationServiceError;
8use crate::user::domain::User;
9
10#[derive(Debug, Clone)]
12pub struct AuthenticationService {
13 authentication_engine: Arc<dyn AuthenticationEngine>,
14}
15
16impl AuthenticationService {
17 pub fn new(authentication_engine: Arc<dyn AuthenticationEngine>) -> Self {
18 Self {
19 authentication_engine,
20 }
21 }
22
23 pub async fn authorize(&self) -> Result<AuthorizeData, AuthenticationServiceError> {
27 Ok(self.authentication_engine.authorize().await?)
28 }
29
30 pub async fn callback(
39 &self,
40 callback_params: CallbackRequestParams,
41 persisted_data: OidcSessionPersisted,
42 ) -> Result<User, AuthenticationServiceError> {
43 Ok(self
44 .authentication_engine
45 .callback(callback_params, persisted_data)
46 .await?)
47 }
48}