|
12 | 12 | // |
13 | 13 | // SPDX-License-Identifier: Apache-2.0 |
14 | 14 |
|
15 | | -use chrono::{DateTime, Utc}; |
16 | | -use std::collections::HashSet; |
17 | | - |
18 | 15 | pub mod group; |
| 16 | +pub mod provider_api; |
19 | 17 | pub mod user; |
20 | 18 |
|
21 | | -use async_trait::async_trait; |
22 | | - |
23 | | -use crate::auth::AuthenticatedInfo; |
24 | | -use crate::identity::IdentityProviderError; |
25 | | -pub use crate::identity::types::group::{Group, GroupCreate, GroupListParameters}; |
26 | | -pub use crate::identity::types::user::*; |
27 | | -use crate::keystone::ServiceState; |
28 | | - |
29 | | -#[async_trait] |
30 | | -pub trait IdentityApi: Send + Sync + Clone { |
31 | | - async fn authenticate_by_password( |
32 | | - &self, |
33 | | - state: &ServiceState, |
34 | | - auth: &UserPasswordAuthRequest, |
35 | | - ) -> Result<AuthenticatedInfo, IdentityProviderError>; |
36 | | - |
37 | | - async fn list_users( |
38 | | - &self, |
39 | | - state: &ServiceState, |
40 | | - params: &UserListParameters, |
41 | | - ) -> Result<impl IntoIterator<Item = UserResponse>, IdentityProviderError>; |
42 | | - |
43 | | - async fn get_user<'a>( |
44 | | - &self, |
45 | | - state: &ServiceState, |
46 | | - user_id: &'a str, |
47 | | - ) -> Result<Option<UserResponse>, IdentityProviderError>; |
48 | | - |
49 | | - async fn find_federated_user<'a>( |
50 | | - &self, |
51 | | - state: &ServiceState, |
52 | | - idp_id: &'a str, |
53 | | - unique_id: &'a str, |
54 | | - ) -> Result<Option<UserResponse>, IdentityProviderError>; |
55 | | - |
56 | | - async fn create_user( |
57 | | - &self, |
58 | | - state: &ServiceState, |
59 | | - user: UserCreate, |
60 | | - ) -> Result<UserResponse, IdentityProviderError>; |
61 | | - |
62 | | - async fn delete_user<'a>( |
63 | | - &self, |
64 | | - state: &ServiceState, |
65 | | - user_id: &'a str, |
66 | | - ) -> Result<(), IdentityProviderError>; |
67 | | - |
68 | | - async fn list_groups( |
69 | | - &self, |
70 | | - state: &ServiceState, |
71 | | - params: &GroupListParameters, |
72 | | - ) -> Result<impl IntoIterator<Item = Group>, IdentityProviderError>; |
73 | | - |
74 | | - async fn get_group<'a>( |
75 | | - &self, |
76 | | - state: &ServiceState, |
77 | | - group_id: &'a str, |
78 | | - ) -> Result<Option<Group>, IdentityProviderError>; |
79 | | - |
80 | | - async fn create_group( |
81 | | - &self, |
82 | | - state: &ServiceState, |
83 | | - group: GroupCreate, |
84 | | - ) -> Result<Group, IdentityProviderError>; |
85 | | - |
86 | | - async fn delete_group<'a>( |
87 | | - &self, |
88 | | - state: &ServiceState, |
89 | | - group_id: &'a str, |
90 | | - ) -> Result<(), IdentityProviderError>; |
91 | | - |
92 | | - /// List groups the user is a member of. |
93 | | - async fn list_groups_of_user<'a>( |
94 | | - &self, |
95 | | - state: &ServiceState, |
96 | | - user_id: &'a str, |
97 | | - ) -> Result<impl IntoIterator<Item = Group>, IdentityProviderError>; |
98 | | - |
99 | | - /// Add the user to the single group. |
100 | | - async fn add_user_to_group<'a>( |
101 | | - &self, |
102 | | - state: &ServiceState, |
103 | | - user_id: &'a str, |
104 | | - group_id: &'a str, |
105 | | - ) -> Result<(), IdentityProviderError>; |
106 | | - |
107 | | - /// Add the user to the single group with expiration. |
108 | | - async fn add_user_to_group_expiring<'a>( |
109 | | - &self, |
110 | | - state: &ServiceState, |
111 | | - user_id: &'a str, |
112 | | - group_id: &'a str, |
113 | | - idp_id: &'a str, |
114 | | - ) -> Result<(), IdentityProviderError>; |
115 | | - |
116 | | - /// Add user group memberships as specified by (uid, gid) tuples. |
117 | | - async fn add_users_to_groups<'a>( |
118 | | - &self, |
119 | | - state: &ServiceState, |
120 | | - memberships: Vec<(&'a str, &'a str)>, |
121 | | - ) -> Result<(), IdentityProviderError>; |
122 | | - |
123 | | - /// Add expiring user group memberships as specified by (uid, gid) tuples. |
124 | | - async fn add_users_to_groups_expiring<'a>( |
125 | | - &self, |
126 | | - state: &ServiceState, |
127 | | - memberships: Vec<(&'a str, &'a str)>, |
128 | | - idp_id: &'a str, |
129 | | - ) -> Result<(), IdentityProviderError>; |
130 | | - |
131 | | - /// Remove the user from the single group. |
132 | | - async fn remove_user_from_group<'a>( |
133 | | - &self, |
134 | | - state: &ServiceState, |
135 | | - user_id: &'a str, |
136 | | - group_id: &'a str, |
137 | | - ) -> Result<(), IdentityProviderError>; |
138 | | - |
139 | | - /// Remove the user from the single group with expiration. |
140 | | - async fn remove_user_from_group_expiring<'a>( |
141 | | - &self, |
142 | | - state: &ServiceState, |
143 | | - user_id: &'a str, |
144 | | - group_id: &'a str, |
145 | | - idp_id: &'a str, |
146 | | - ) -> Result<(), IdentityProviderError>; |
147 | | - |
148 | | - /// Remove the user from specified groups. |
149 | | - async fn remove_user_from_groups<'a>( |
150 | | - &self, |
151 | | - state: &ServiceState, |
152 | | - user_id: &'a str, |
153 | | - group_ids: HashSet<&'a str>, |
154 | | - ) -> Result<(), IdentityProviderError>; |
155 | | - |
156 | | - /// Remove the user from specified groups with expiration. |
157 | | - async fn remove_user_from_groups_expiring<'a>( |
158 | | - &self, |
159 | | - state: &ServiceState, |
160 | | - user_id: &'a str, |
161 | | - group_ids: HashSet<&'a str>, |
162 | | - idp_id: &'a str, |
163 | | - ) -> Result<(), IdentityProviderError>; |
164 | | - |
165 | | - /// Set group memberships of the user. |
166 | | - async fn set_user_groups<'a>( |
167 | | - &self, |
168 | | - state: &ServiceState, |
169 | | - user_id: &'a str, |
170 | | - group_ids: HashSet<&'a str>, |
171 | | - ) -> Result<(), IdentityProviderError>; |
172 | | - |
173 | | - /// Set expiring group memberships of the user. |
174 | | - async fn set_user_groups_expiring<'a>( |
175 | | - &self, |
176 | | - state: &ServiceState, |
177 | | - user_id: &'a str, |
178 | | - group_ids: HashSet<&'a str>, |
179 | | - idp_id: &'a str, |
180 | | - last_verified: Option<&'a DateTime<Utc>>, |
181 | | - ) -> Result<(), IdentityProviderError>; |
182 | | -} |
| 19 | +pub use group::*; |
| 20 | +pub use provider_api::IdentityApi; |
| 21 | +pub use user::*; |
0 commit comments