bitwarden_api_identity/apis/
sso_api.rs1use reqwest;
12use serde::{de::Error as _, Deserialize, Serialize};
13
14use super::{configuration, ContentType, Error};
15use crate::{apis::ResponseContent, models};
16
17#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum SsoExternalCallbackGetError {
21 UnknownValue(serde_json::Value),
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26#[serde(untagged)]
27pub enum SsoExternalChallengeGetError {
28 UnknownValue(serde_json::Value),
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(untagged)]
34pub enum SsoLoginGetError {
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum SsoPreValidateGetError {
42 UnknownValue(serde_json::Value),
43}
44
45pub async fn sso_external_callback_get(
46 configuration: &configuration::Configuration,
47) -> Result<(), Error<SsoExternalCallbackGetError>> {
48 let uri_str = format!("{}/sso/ExternalCallback", configuration.base_path);
49 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
50
51 if let Some(ref user_agent) = configuration.user_agent {
52 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
53 }
54
55 let req = req_builder.build()?;
56 let resp = configuration.client.execute(req).await?;
57
58 let status = resp.status();
59
60 if !status.is_client_error() && !status.is_server_error() {
61 Ok(())
62 } else {
63 let content = resp.text().await?;
64 let entity: Option<SsoExternalCallbackGetError> = serde_json::from_str(&content).ok();
65 Err(Error::ResponseError(ResponseContent {
66 status,
67 content,
68 entity,
69 }))
70 }
71}
72
73pub async fn sso_external_challenge_get(
74 configuration: &configuration::Configuration,
75 domain_hint: Option<&str>,
76 return_url: Option<&str>,
77 user_identifier: Option<&str>,
78 sso_token: Option<&str>,
79) -> Result<(), Error<SsoExternalChallengeGetError>> {
80 let p_domain_hint = domain_hint;
82 let p_return_url = return_url;
83 let p_user_identifier = user_identifier;
84 let p_sso_token = sso_token;
85
86 let uri_str = format!("{}/sso/ExternalChallenge", configuration.base_path);
87 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
88
89 if let Some(ref param_value) = p_domain_hint {
90 req_builder = req_builder.query(&[("domainHint", ¶m_value.to_string())]);
91 }
92 if let Some(ref param_value) = p_return_url {
93 req_builder = req_builder.query(&[("returnUrl", ¶m_value.to_string())]);
94 }
95 if let Some(ref param_value) = p_user_identifier {
96 req_builder = req_builder.query(&[("userIdentifier", ¶m_value.to_string())]);
97 }
98 if let Some(ref param_value) = p_sso_token {
99 req_builder = req_builder.query(&[("ssoToken", ¶m_value.to_string())]);
100 }
101 if let Some(ref user_agent) = configuration.user_agent {
102 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
103 }
104
105 let req = req_builder.build()?;
106 let resp = configuration.client.execute(req).await?;
107
108 let status = resp.status();
109
110 if !status.is_client_error() && !status.is_server_error() {
111 Ok(())
112 } else {
113 let content = resp.text().await?;
114 let entity: Option<SsoExternalChallengeGetError> = serde_json::from_str(&content).ok();
115 Err(Error::ResponseError(ResponseContent {
116 status,
117 content,
118 entity,
119 }))
120 }
121}
122
123pub async fn sso_login_get(
124 configuration: &configuration::Configuration,
125 return_url: Option<&str>,
126) -> Result<(), Error<SsoLoginGetError>> {
127 let p_return_url = return_url;
129
130 let uri_str = format!("{}/sso/Login", configuration.base_path);
131 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
132
133 if let Some(ref param_value) = p_return_url {
134 req_builder = req_builder.query(&[("returnUrl", ¶m_value.to_string())]);
135 }
136 if let Some(ref user_agent) = configuration.user_agent {
137 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
138 }
139
140 let req = req_builder.build()?;
141 let resp = configuration.client.execute(req).await?;
142
143 let status = resp.status();
144
145 if !status.is_client_error() && !status.is_server_error() {
146 Ok(())
147 } else {
148 let content = resp.text().await?;
149 let entity: Option<SsoLoginGetError> = serde_json::from_str(&content).ok();
150 Err(Error::ResponseError(ResponseContent {
151 status,
152 content,
153 entity,
154 }))
155 }
156}
157
158pub async fn sso_pre_validate_get(
159 configuration: &configuration::Configuration,
160 domain_hint: Option<&str>,
161) -> Result<(), Error<SsoPreValidateGetError>> {
162 let p_domain_hint = domain_hint;
164
165 let uri_str = format!("{}/sso/PreValidate", configuration.base_path);
166 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
167
168 if let Some(ref param_value) = p_domain_hint {
169 req_builder = req_builder.query(&[("domainHint", ¶m_value.to_string())]);
170 }
171 if let Some(ref user_agent) = configuration.user_agent {
172 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
173 }
174
175 let req = req_builder.build()?;
176 let resp = configuration.client.execute(req).await?;
177
178 let status = resp.status();
179
180 if !status.is_client_error() && !status.is_server_error() {
181 Ok(())
182 } else {
183 let content = resp.text().await?;
184 let entity: Option<SsoPreValidateGetError> = serde_json::from_str(&content).ok();
185 Err(Error::ResponseError(ResponseContent {
186 status,
187 content,
188 entity,
189 }))
190 }
191}