openstack_keystone_core/identity/
backend.rs1use async_trait::async_trait;
16use chrono::{DateTime, Utc};
17use std::collections::HashSet;
18
19use crate::auth::AuthenticatedInfo;
20use crate::identity::IdentityProviderError;
21use crate::identity::types::*;
22use crate::keystone::ServiceState;
23
24#[cfg_attr(test, mockall::automock)]
25#[async_trait]
26pub trait IdentityBackend: Send + Sync {
27 async fn add_user_to_group<'a>(
29 &self,
30 state: &ServiceState,
31 user_id: &'a str,
32 group_id: &'a str,
33 ) -> Result<(), IdentityProviderError>;
34
35 async fn add_user_to_group_expiring<'a>(
37 &self,
38 state: &ServiceState,
39 user_id: &'a str,
40 group_id: &'a str,
41 idp_id: &'a str,
42 ) -> Result<(), IdentityProviderError>;
43
44 async fn add_users_to_groups<'a>(
46 &self,
47 state: &ServiceState,
48 memberships: Vec<(&'a str, &'a str)>,
49 ) -> Result<(), IdentityProviderError>;
50
51 async fn add_users_to_groups_expiring<'a>(
53 &self,
54 state: &ServiceState,
55 memberships: Vec<(&'a str, &'a str)>,
56 idp_id: &'a str,
57 ) -> Result<(), IdentityProviderError>;
58
59 async fn authenticate_by_password(
61 &self,
62 state: &ServiceState,
63 auth: &UserPasswordAuthRequest,
64 ) -> Result<AuthenticatedInfo, IdentityProviderError>;
65
66 async fn create_group(
68 &self,
69 state: &ServiceState,
70 group: GroupCreate,
71 ) -> Result<Group, IdentityProviderError>;
72
73 async fn create_service_account(
75 &self,
76 state: &ServiceState,
77 sa: ServiceAccountCreate,
78 ) -> Result<ServiceAccount, IdentityProviderError>;
79
80 async fn create_user(
82 &self,
83 state: &ServiceState,
84 user: UserCreate,
85 ) -> Result<UserResponse, IdentityProviderError>;
86
87 async fn delete_group<'a>(
89 &self,
90 state: &ServiceState,
91 group_id: &'a str,
92 ) -> Result<(), IdentityProviderError>;
93
94 async fn delete_user<'a>(
96 &self,
97 state: &ServiceState,
98 user_id: &'a str,
99 ) -> Result<(), IdentityProviderError>;
100
101 async fn get_group<'a>(
103 &self,
104 state: &ServiceState,
105 group_id: &'a str,
106 ) -> Result<Option<Group>, IdentityProviderError>;
107
108 async fn get_service_account<'a>(
110 &self,
111 state: &ServiceState,
112 user_id: &'a str,
113 ) -> Result<Option<ServiceAccount>, IdentityProviderError>;
114
115 async fn get_user<'a>(
117 &self,
118 state: &ServiceState,
119 user_id: &'a str,
120 ) -> Result<Option<UserResponse>, IdentityProviderError>;
121
122 async fn get_user_domain_id<'a>(
124 &self,
125 state: &ServiceState,
126 user_id: &'a str,
127 ) -> Result<String, IdentityProviderError>;
128
129 async fn find_federated_user<'a>(
131 &self,
132 state: &ServiceState,
133 idp_id: &'a str,
134 unique_id: &'a str,
135 ) -> Result<Option<UserResponse>, IdentityProviderError>;
136
137 async fn list_groups(
139 &self,
140 state: &ServiceState,
141 params: &GroupListParameters,
142 ) -> Result<Vec<Group>, IdentityProviderError>;
143
144 async fn list_users(
146 &self,
147 state: &ServiceState,
148 params: &UserListParameters,
149 ) -> Result<Vec<UserResponse>, IdentityProviderError>;
150
151 async fn list_groups_of_user<'a>(
153 &self,
154 state: &ServiceState,
155 user_id: &'a str,
156 ) -> Result<Vec<Group>, IdentityProviderError>;
157
158 async fn remove_user_from_group<'a>(
160 &self,
161 state: &ServiceState,
162 user_id: &'a str,
163 group_id: &'a str,
164 ) -> Result<(), IdentityProviderError>;
165
166 async fn remove_user_from_group_expiring<'a>(
168 &self,
169 state: &ServiceState,
170 user_id: &'a str,
171 group_id: &'a str,
172 idp_id: &'a str,
173 ) -> Result<(), IdentityProviderError>;
174
175 async fn remove_user_from_groups<'a>(
177 &self,
178 state: &ServiceState,
179 user_id: &'a str,
180 group_ids: HashSet<&'a str>,
181 ) -> Result<(), IdentityProviderError>;
182
183 async fn remove_user_from_groups_expiring<'a>(
185 &self,
186 state: &ServiceState,
187 user_id: &'a str,
188 group_ids: HashSet<&'a str>,
189 idp_id: &'a str,
190 ) -> Result<(), IdentityProviderError>;
191
192 async fn set_user_groups<'a>(
194 &self,
195 state: &ServiceState,
196 user_id: &'a str,
197 group_ids: HashSet<&'a str>,
198 ) -> Result<(), IdentityProviderError>;
199
200 async fn set_user_groups_expiring<'a>(
202 &self,
203 state: &ServiceState,
204 user_id: &'a str,
205 group_ids: HashSet<&'a str>,
206 idp_id: &'a str,
207 last_verified: Option<&'a DateTime<Utc>>,
208 ) -> Result<(), IdentityProviderError>;
209}