1pub mod realm;
2
3#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
4pub struct GetResponseItem {
5 #[doc = "A comment. The GUI use this text when you select a domain (Realm) on the login window."]
6 #[serde(skip_serializing_if = "Option::is_none", default)]
7 pub comment: Option<String>,
8 pub realm: String,
9 #[doc = "Two-factor authentication provider."]
10 #[serde(skip_serializing_if = "Option::is_none", default)]
11 pub tfa: Option<String>,
12 pub r#type: String,
13}
14
15#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
16pub struct PostParameters {
17 #[doc = "Specifies the Authentication Context Class Reference values that theAuthorization Server is being requested to use for the Auth Request."]
18 #[serde(
19 rename = "acr-values",
20 skip_serializing_if = "Option::is_none",
21 default
22 )]
23 pub acr_values: Option<String>,
24 #[doc = "Automatically create users if they do not exist."]
25 #[serde(
26 skip_serializing_if = "Option::is_none",
27 default,
28 deserialize_with = "crate::common::deserialize_option_bool_lax",
29 serialize_with = "crate::common::serialize_option_bool_as_u64"
30 )]
31 pub autocreate: Option<bool>,
32 #[doc = "LDAP base domain name"]
33 #[serde(skip_serializing_if = "Option::is_none", default)]
34 pub base_dn: Option<String>,
35 #[doc = "LDAP bind domain name"]
36 #[serde(skip_serializing_if = "Option::is_none", default)]
37 pub bind_dn: Option<String>,
38 #[doc = "Path to the CA certificate store"]
39 #[serde(skip_serializing_if = "Option::is_none", default)]
40 pub capath: Option<String>,
41 #[doc = "username is case-sensitive"]
42 #[serde(
43 rename = "case-sensitive",
44 skip_serializing_if = "Option::is_none",
45 default,
46 deserialize_with = "crate::common::deserialize_option_bool_lax",
47 serialize_with = "crate::common::serialize_option_bool_as_u64"
48 )]
49 pub case_sensitive: Option<bool>,
50 #[doc = "Path to the client certificate"]
51 #[serde(skip_serializing_if = "Option::is_none", default)]
52 pub cert: Option<String>,
53 #[doc = "Path to the client certificate key"]
54 #[serde(skip_serializing_if = "Option::is_none", default)]
55 pub certkey: Option<String>,
56 #[doc = "OpenID Client ID"]
57 #[serde(rename = "client-id", skip_serializing_if = "Option::is_none", default)]
58 pub client_id: Option<String>,
59 #[doc = "OpenID Client Key"]
60 #[serde(
61 rename = "client-key",
62 skip_serializing_if = "Option::is_none",
63 default
64 )]
65 pub client_key: Option<String>,
66 #[doc = "Description."]
67 #[serde(skip_serializing_if = "Option::is_none", default)]
68 pub comment: Option<String>,
69 #[doc = "Use this as default realm"]
70 #[serde(
71 skip_serializing_if = "Option::is_none",
72 default,
73 deserialize_with = "crate::common::deserialize_option_bool_lax",
74 serialize_with = "crate::common::serialize_option_bool_as_u64"
75 )]
76 pub default: Option<bool>,
77 #[doc = "AD domain name"]
78 #[serde(skip_serializing_if = "Option::is_none", default)]
79 pub domain: Option<String>,
80 #[doc = "LDAP filter for user sync."]
81 #[serde(skip_serializing_if = "Option::is_none", default)]
82 pub filter: Option<String>,
83 #[doc = "The objectclasses for groups."]
84 #[serde(skip_serializing_if = "Option::is_none", default)]
85 pub group_classes: Option<String>,
86 #[doc = "LDAP base domain name for group sync. If not set, the base_dn will be used."]
87 #[serde(skip_serializing_if = "Option::is_none", default)]
88 pub group_dn: Option<String>,
89 #[doc = "LDAP filter for group sync."]
90 #[serde(skip_serializing_if = "Option::is_none", default)]
91 pub group_filter: Option<String>,
92 #[doc = "LDAP attribute representing a groups name. If not set or found, the first value of the DN will be used as name."]
93 #[serde(skip_serializing_if = "Option::is_none", default)]
94 pub group_name_attr: Option<String>,
95 #[doc = "OpenID Issuer Url"]
96 #[serde(
97 rename = "issuer-url",
98 skip_serializing_if = "Option::is_none",
99 default
100 )]
101 pub issuer_url: Option<String>,
102 #[doc = "LDAP protocol mode."]
103 #[serde(skip_serializing_if = "Option::is_none", default)]
104 pub mode: Option<String>,
105 #[doc = "LDAP bind password. Will be stored in '/etc/pve/priv/realm/<REALM>.pw'."]
106 #[serde(skip_serializing_if = "Option::is_none", default)]
107 pub password: Option<String>,
108 #[doc = "Server port."]
109 #[serde(skip_serializing_if = "Option::is_none", default)]
110 pub port: Option<u64>,
111 #[doc = "Specifies whether the Authorization Server prompts the End-User for reauthentication and consent."]
112 #[serde(skip_serializing_if = "Option::is_none", default)]
113 pub prompt: Option<String>,
114 #[doc = "Authentication domain ID"]
115 pub realm: String,
116 #[doc = "Specifies the scopes (user details) that should be authorized and returned, for example 'email' or 'profile'."]
117 #[serde(skip_serializing_if = "Option::is_none", default)]
118 pub scopes: Option<String>,
119 #[doc = "Use secure LDAPS protocol. DEPRECATED: use 'mode' instead."]
120 #[serde(
121 skip_serializing_if = "Option::is_none",
122 default,
123 deserialize_with = "crate::common::deserialize_option_bool_lax",
124 serialize_with = "crate::common::serialize_option_bool_as_u64"
125 )]
126 pub secure: Option<bool>,
127 #[doc = "Server IP address (or DNS name)"]
128 #[serde(skip_serializing_if = "Option::is_none", default)]
129 pub server1: Option<String>,
130 #[doc = "Fallback Server IP address (or DNS name)"]
131 #[serde(skip_serializing_if = "Option::is_none", default)]
132 pub server2: Option<String>,
133 #[doc = "LDAPS TLS/SSL version. It's not recommended to use version older than 1.2!"]
134 #[serde(skip_serializing_if = "Option::is_none", default)]
135 pub sslversion: Option<String>,
136 #[doc = "The default options for behavior of synchronizations."]
137 #[serde(
138 rename = "sync-defaults-options",
139 skip_serializing_if = "Option::is_none",
140 default
141 )]
142 pub sync_defaults_options: Option<String>,
143 #[doc = "Comma separated list of key=value pairs for specifying which LDAP attributes map to which PVE user field. For example, to map the LDAP attribute 'mail' to PVEs 'email', write 'email=mail'. By default, each PVE user field is represented by an LDAP attribute of the same name."]
144 #[serde(skip_serializing_if = "Option::is_none", default)]
145 pub sync_attributes: Option<String>,
146 #[doc = "Use Two-factor authentication."]
147 #[serde(skip_serializing_if = "Option::is_none", default)]
148 pub tfa: Option<String>,
149 #[doc = "Realm type."]
150 pub r#type: String,
151 #[doc = "LDAP user attribute name"]
152 #[serde(skip_serializing_if = "Option::is_none", default)]
153 pub user_attr: Option<String>,
154 #[doc = "The objectclasses for users."]
155 #[serde(skip_serializing_if = "Option::is_none", default)]
156 pub user_classes: Option<String>,
157 #[doc = "OpenID claim used to generate the unique username."]
158 #[serde(
159 rename = "username-claim",
160 skip_serializing_if = "Option::is_none",
161 default
162 )]
163 pub username_claim: Option<String>,
164 #[doc = "Verify the server's SSL certificate"]
165 #[serde(
166 skip_serializing_if = "Option::is_none",
167 default,
168 deserialize_with = "crate::common::deserialize_option_bool_lax",
169 serialize_with = "crate::common::serialize_option_bool_as_u64"
170 )]
171 pub verify: Option<bool>,
172}
173
174#[derive(Debug, Clone)]
175pub struct DomainsClient<T> {
176 client: T,
177 path: String,
178}
179
180impl<T> DomainsClient<T>
181where
182 T: Clone,
183{
184 pub fn new(client: T, parent_path: &str) -> Self {
185 Self {
186 client,
187 path: format!("{}/{}", parent_path, "domains"),
188 }
189 }
190
191 pub fn realm(&self, realm: &str) -> realm::RealmClient<T> {
192 realm::RealmClient::<T>::new(self.client.clone(), &self.path, realm)
193 }
194}
195impl<T> DomainsClient<T>
196where
197 T: crate::client::HttpClient,
198{
199 #[doc = "Authentication domain index."]
200 pub fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
201 self.client.get(&self.path, &())
202 }
203
204 #[doc = "Add an authentication server."]
205 pub fn post(&self, parameters: PostParameters) -> Result<(), T::Error> {
206 self.client.post(&self.path, ¶meters)
207 }
208}
209#[derive(Debug, Clone)]
210pub struct AsyncDomainsClient<T> {
211 client: T,
212 path: String,
213}
214
215impl<T> AsyncDomainsClient<T>
216where
217 T: Clone,
218{
219 pub fn new(client: T, parent_path: &str) -> Self {
220 Self {
221 client,
222 path: format!("{}/{}", parent_path, "domains"),
223 }
224 }
225
226 pub fn realm(&self, realm: &str) -> realm::AsyncRealmClient<T> {
227 realm::AsyncRealmClient::<T>::new(self.client.clone(), &self.path, realm)
228 }
229}
230impl<T> AsyncDomainsClient<T>
231where
232 T: crate::client::AsyncHttpClient,
233{
234 #[doc = "Authentication domain index."]
235 pub async fn get(&self) -> Result<Vec<GetResponseItem>, T::Error> {
236 self.client.get(&self.path, &()).await
237 }
238
239 #[doc = "Add an authentication server."]
240 pub async fn post(&self, parameters: PostParameters) -> Result<(), T::Error> {
241 self.client.post(&self.path, ¶meters).await
242 }
243}