Skip to main content

rs_service_client/service/
auth.rs

1//! This module provides an implementation of AuthInterface for interacting with the Factory+
2//! Auth service.
3
4use std::collections::HashMap;
5use std::sync::Arc;
6
7use tokio::sync::Mutex;
8
9use crate::service::response::TokenStruct;
10use crate::service::ServiceType;
11
12pub struct AuthInterface {
13    service_type: ServiceType,
14    service_username: String,
15    service_password: String,
16    http_client: Arc<reqwest::Client>,
17    directory_url: String,
18    pub service_url: String,
19    tokens: Arc<Mutex<HashMap<ServiceType, TokenStruct>>>,
20}
21
22impl AuthInterface {
23    pub fn from(
24        service_username: String,
25        service_password: String,
26        http_client: Arc<reqwest::Client>,
27        directory_url: String,
28        service_url: String,
29        tokens: Arc<Mutex<HashMap<ServiceType, TokenStruct>>>,
30    ) -> Self {
31        AuthInterface {
32            service_type: ServiceType::Authentication,
33            service_username,
34            service_password,
35            http_client: Arc::clone(&http_client),
36            directory_url,
37            service_url,
38            tokens,
39        }
40    }
41
42    pub fn check_acl(&self) {
43        todo!()
44    }
45
46    pub fn fetch_acl(&self) {
47        todo!()
48    }
49
50    pub fn resolve_principal(&self) {
51        todo!()
52    }
53
54    pub fn find_principal(&self) {
55        todo!()
56    }
57
58    pub fn add_principal(&self) {
59        todo!()
60    }
61
62    pub fn create_principal(&self) {
63        todo!()
64    }
65
66    pub fn add_ace(&self) {
67        todo!()
68    }
69
70    pub fn delete_ace(&self) {
71        todo!()
72    }
73
74    pub fn add_to_group(&self) {
75        todo!()
76    }
77
78    pub fn remove_from_group(&self) {
79        todo!()
80    }
81
82    fn resolve_principal_by_address(&self) {
83        todo!()
84    }
85
86    fn edit_ace(&self) {
87        todo!()
88    }
89}
90
91pub mod auth_models {
92    //! Contains structs and implementations for modelling Auth requests and responses.
93
94    use crate::sparkplug::util::address::Address;
95
96    pub struct PostAceBody {
97        pub permission: uuid::Uuid,
98        pub target: uuid::Uuid,
99        pub ace_action: AceAction,
100        pub principal: uuid::Uuid,
101        pub kerberos: String,
102    }
103
104    pub struct PrincipalMapping {
105        pub uuid: uuid::Uuid,
106        pub kerberos: String,
107        pub sparkplug: Address,
108    }
109
110    pub struct FetchAclQuery {
111        principal: String,
112        permission: String,
113        by_uuid: bool,
114    }
115
116    pub struct Ace {
117        permission: uuid::Uuid,
118        target: uuid::Uuid,
119        principal: uuid::Uuid,
120        kerberos: String,
121    }
122
123    pub struct Acl {
124        acl_vec: Vec<Acl>,
125    }
126
127    pub enum AceAction {
128        Add,
129        Delete,
130    }
131}