1#![allow(clippy::doc_markdown)]
8
9#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
18#[non_exhaustive]
19pub enum OAuthAccessTokenType {
20 Bearer,
22
23 Na,
25
26 PoP,
28
29 DPoP,
31
32 Unknown(String),
34}
35
36impl core::fmt::Display for OAuthAccessTokenType {
37 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
38 match self {
39 Self::Bearer => write!(f, "Bearer"),
40 Self::Na => write!(f, "N_A"),
41 Self::PoP => write!(f, "PoP"),
42 Self::DPoP => write!(f, "DPoP"),
43 Self::Unknown(value) => write!(f, "{value}"),
44 }
45 }
46}
47
48impl core::str::FromStr for OAuthAccessTokenType {
49 type Err = core::convert::Infallible;
50
51 fn from_str(s: &str) -> Result<Self, Self::Err> {
52 match s {
53 "Bearer" => Ok(Self::Bearer),
54 "N_A" => Ok(Self::Na),
55 "PoP" => Ok(Self::PoP),
56 "DPoP" => Ok(Self::DPoP),
57 value => Ok(Self::Unknown(value.to_owned())),
58 }
59 }
60}
61
62impl<'de> serde::Deserialize<'de> for OAuthAccessTokenType {
63 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
64 where
65 D: serde::de::Deserializer<'de>,
66 {
67 let s = String::deserialize(deserializer)?;
68 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
69 }
70}
71
72impl serde::Serialize for OAuthAccessTokenType {
73 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
74 where
75 S: serde::ser::Serializer,
76 {
77 serializer.serialize_str(&self.to_string())
78 }
79}
80
81impl schemars::JsonSchema for OAuthAccessTokenType {
82 fn schema_name() -> String {
83 "OAuthAccessTokenType".to_owned()
84 }
85
86 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
87 let enums = vec![
88 schemars::schema::SchemaObject {
90 const_value: Some("Bearer".into()),
91 ..Default::default()
92 }
93 .into(),
94 schemars::schema::SchemaObject {
96 const_value: Some("N_A".into()),
97 ..Default::default()
98 }
99 .into(),
100 schemars::schema::SchemaObject {
102 const_value: Some("PoP".into()),
103 ..Default::default()
104 }
105 .into(),
106 schemars::schema::SchemaObject {
108 const_value: Some("DPoP".into()),
109 ..Default::default()
110 }
111 .into(),
112 ];
113
114 let description = r"OAuth Access Token Type";
115 schemars::schema::SchemaObject {
116 metadata: Some(Box::new(schemars::schema::Metadata {
117 description: Some(description.to_owned()),
118 ..Default::default()
119 })),
120 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
121 any_of: Some(enums),
122 ..Default::default()
123 })),
124 ..Default::default()
125 }
126 .into()
127 }
128}
129
130#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
134pub enum OAuthAuthorizationEndpointResponseType {
135 Code,
137
138 CodeIdToken,
140
141 CodeIdTokenToken,
143
144 CodeToken,
146
147 IdToken,
149
150 IdTokenToken,
152
153 None,
155
156 Token,
158}
159
160impl core::fmt::Display for OAuthAuthorizationEndpointResponseType {
161 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
162 match self {
163 Self::Code => write!(f, "code"),
164 Self::CodeIdToken => write!(f, "code id_token"),
165 Self::CodeIdTokenToken => write!(f, "code id_token token"),
166 Self::CodeToken => write!(f, "code token"),
167 Self::IdToken => write!(f, "id_token"),
168 Self::IdTokenToken => write!(f, "id_token token"),
169 Self::None => write!(f, "none"),
170 Self::Token => write!(f, "token"),
171 }
172 }
173}
174
175impl core::str::FromStr for OAuthAuthorizationEndpointResponseType {
176 type Err = crate::ParseError;
177
178 fn from_str(s: &str) -> Result<Self, Self::Err> {
179 match s {
180 "code" => Ok(Self::Code),
181 "code id_token" => Ok(Self::CodeIdToken),
182 "code id_token token" => Ok(Self::CodeIdTokenToken),
183 "code token" => Ok(Self::CodeToken),
184 "id_token" => Ok(Self::IdToken),
185 "id_token token" => Ok(Self::IdTokenToken),
186 "none" => Ok(Self::None),
187 "token" => Ok(Self::Token),
188 _ => Err(crate::ParseError::new()),
189 }
190 }
191}
192
193impl<'de> serde::Deserialize<'de> for OAuthAuthorizationEndpointResponseType {
194 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
195 where
196 D: serde::de::Deserializer<'de>,
197 {
198 let s = String::deserialize(deserializer)?;
199 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
200 }
201}
202
203impl serde::Serialize for OAuthAuthorizationEndpointResponseType {
204 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
205 where
206 S: serde::ser::Serializer,
207 {
208 serializer.serialize_str(&self.to_string())
209 }
210}
211
212impl schemars::JsonSchema for OAuthAuthorizationEndpointResponseType {
213 fn schema_name() -> String {
214 "OAuthAuthorizationEndpointResponseType".to_owned()
215 }
216
217 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
218 let enums = vec![
219 schemars::schema::SchemaObject {
221 const_value: Some("code".into()),
222 ..Default::default()
223 }
224 .into(),
225 schemars::schema::SchemaObject {
227 const_value: Some("code id_token".into()),
228 ..Default::default()
229 }
230 .into(),
231 schemars::schema::SchemaObject {
233 const_value: Some("code id_token token".into()),
234 ..Default::default()
235 }
236 .into(),
237 schemars::schema::SchemaObject {
239 const_value: Some("code token".into()),
240 ..Default::default()
241 }
242 .into(),
243 schemars::schema::SchemaObject {
245 const_value: Some("id_token".into()),
246 ..Default::default()
247 }
248 .into(),
249 schemars::schema::SchemaObject {
251 const_value: Some("id_token token".into()),
252 ..Default::default()
253 }
254 .into(),
255 schemars::schema::SchemaObject {
257 const_value: Some("none".into()),
258 ..Default::default()
259 }
260 .into(),
261 schemars::schema::SchemaObject {
263 const_value: Some("token".into()),
264 ..Default::default()
265 }
266 .into(),
267 ];
268
269 let description = r"OAuth Authorization Endpoint Response Type";
270 schemars::schema::SchemaObject {
271 metadata: Some(Box::new(schemars::schema::Metadata {
272 description: Some(description.to_owned()),
273 ..Default::default()
274 })),
275 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
276 any_of: Some(enums),
277 ..Default::default()
278 })),
279 ..Default::default()
280 }
281 .into()
282 }
283}
284
285#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
289#[non_exhaustive]
290pub enum OAuthTokenTypeHint {
291 AccessToken,
293
294 RefreshToken,
296
297 Pct,
299
300 Unknown(String),
302}
303
304impl core::fmt::Display for OAuthTokenTypeHint {
305 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
306 match self {
307 Self::AccessToken => write!(f, "access_token"),
308 Self::RefreshToken => write!(f, "refresh_token"),
309 Self::Pct => write!(f, "pct"),
310 Self::Unknown(value) => write!(f, "{value}"),
311 }
312 }
313}
314
315impl core::str::FromStr for OAuthTokenTypeHint {
316 type Err = core::convert::Infallible;
317
318 fn from_str(s: &str) -> Result<Self, Self::Err> {
319 match s {
320 "access_token" => Ok(Self::AccessToken),
321 "refresh_token" => Ok(Self::RefreshToken),
322 "pct" => Ok(Self::Pct),
323 value => Ok(Self::Unknown(value.to_owned())),
324 }
325 }
326}
327
328impl<'de> serde::Deserialize<'de> for OAuthTokenTypeHint {
329 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
330 where
331 D: serde::de::Deserializer<'de>,
332 {
333 let s = String::deserialize(deserializer)?;
334 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
335 }
336}
337
338impl serde::Serialize for OAuthTokenTypeHint {
339 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
340 where
341 S: serde::ser::Serializer,
342 {
343 serializer.serialize_str(&self.to_string())
344 }
345}
346
347impl schemars::JsonSchema for OAuthTokenTypeHint {
348 fn schema_name() -> String {
349 "OAuthTokenTypeHint".to_owned()
350 }
351
352 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
353 let enums = vec![
354 schemars::schema::SchemaObject {
356 const_value: Some("access_token".into()),
357 ..Default::default()
358 }
359 .into(),
360 schemars::schema::SchemaObject {
362 const_value: Some("refresh_token".into()),
363 ..Default::default()
364 }
365 .into(),
366 schemars::schema::SchemaObject {
368 const_value: Some("pct".into()),
369 ..Default::default()
370 }
371 .into(),
372 ];
373
374 let description = r"OAuth Token Type Hint";
375 schemars::schema::SchemaObject {
376 metadata: Some(Box::new(schemars::schema::Metadata {
377 description: Some(description.to_owned()),
378 ..Default::default()
379 })),
380 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
381 any_of: Some(enums),
382 ..Default::default()
383 })),
384 ..Default::default()
385 }
386 .into()
387 }
388}
389
390#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
394#[non_exhaustive]
395pub enum OAuthClientAuthenticationMethod {
396 None,
398
399 ClientSecretPost,
401
402 ClientSecretBasic,
404
405 ClientSecretJwt,
407
408 PrivateKeyJwt,
410
411 TlsClientAuth,
413
414 SelfSignedTlsClientAuth,
416
417 Unknown(String),
419}
420
421impl core::fmt::Display for OAuthClientAuthenticationMethod {
422 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
423 match self {
424 Self::None => write!(f, "none"),
425 Self::ClientSecretPost => write!(f, "client_secret_post"),
426 Self::ClientSecretBasic => write!(f, "client_secret_basic"),
427 Self::ClientSecretJwt => write!(f, "client_secret_jwt"),
428 Self::PrivateKeyJwt => write!(f, "private_key_jwt"),
429 Self::TlsClientAuth => write!(f, "tls_client_auth"),
430 Self::SelfSignedTlsClientAuth => write!(f, "self_signed_tls_client_auth"),
431 Self::Unknown(value) => write!(f, "{value}"),
432 }
433 }
434}
435
436impl core::str::FromStr for OAuthClientAuthenticationMethod {
437 type Err = core::convert::Infallible;
438
439 fn from_str(s: &str) -> Result<Self, Self::Err> {
440 match s {
441 "none" => Ok(Self::None),
442 "client_secret_post" => Ok(Self::ClientSecretPost),
443 "client_secret_basic" => Ok(Self::ClientSecretBasic),
444 "client_secret_jwt" => Ok(Self::ClientSecretJwt),
445 "private_key_jwt" => Ok(Self::PrivateKeyJwt),
446 "tls_client_auth" => Ok(Self::TlsClientAuth),
447 "self_signed_tls_client_auth" => Ok(Self::SelfSignedTlsClientAuth),
448 value => Ok(Self::Unknown(value.to_owned())),
449 }
450 }
451}
452
453impl<'de> serde::Deserialize<'de> for OAuthClientAuthenticationMethod {
454 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
455 where
456 D: serde::de::Deserializer<'de>,
457 {
458 let s = String::deserialize(deserializer)?;
459 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
460 }
461}
462
463impl serde::Serialize for OAuthClientAuthenticationMethod {
464 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
465 where
466 S: serde::ser::Serializer,
467 {
468 serializer.serialize_str(&self.to_string())
469 }
470}
471
472impl schemars::JsonSchema for OAuthClientAuthenticationMethod {
473 fn schema_name() -> String {
474 "OAuthClientAuthenticationMethod".to_owned()
475 }
476
477 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
478 let enums = vec![
479 schemars::schema::SchemaObject {
481 const_value: Some("none".into()),
482 ..Default::default()
483 }
484 .into(),
485 schemars::schema::SchemaObject {
487 const_value: Some("client_secret_post".into()),
488 ..Default::default()
489 }
490 .into(),
491 schemars::schema::SchemaObject {
493 const_value: Some("client_secret_basic".into()),
494 ..Default::default()
495 }
496 .into(),
497 schemars::schema::SchemaObject {
499 const_value: Some("client_secret_jwt".into()),
500 ..Default::default()
501 }
502 .into(),
503 schemars::schema::SchemaObject {
505 const_value: Some("private_key_jwt".into()),
506 ..Default::default()
507 }
508 .into(),
509 schemars::schema::SchemaObject {
511 const_value: Some("tls_client_auth".into()),
512 ..Default::default()
513 }
514 .into(),
515 schemars::schema::SchemaObject {
517 const_value: Some("self_signed_tls_client_auth".into()),
518 ..Default::default()
519 }
520 .into(),
521 ];
522
523 let description = r"OAuth Token Endpoint Authentication Method";
524 schemars::schema::SchemaObject {
525 metadata: Some(Box::new(schemars::schema::Metadata {
526 description: Some(description.to_owned()),
527 ..Default::default()
528 })),
529 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
530 any_of: Some(enums),
531 ..Default::default()
532 })),
533 ..Default::default()
534 }
535 .into()
536 }
537}
538
539#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
543#[non_exhaustive]
544pub enum PkceCodeChallengeMethod {
545 Plain,
547
548 S256,
550
551 Unknown(String),
553}
554
555impl core::fmt::Display for PkceCodeChallengeMethod {
556 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
557 match self {
558 Self::Plain => write!(f, "plain"),
559 Self::S256 => write!(f, "S256"),
560 Self::Unknown(value) => write!(f, "{value}"),
561 }
562 }
563}
564
565impl core::str::FromStr for PkceCodeChallengeMethod {
566 type Err = core::convert::Infallible;
567
568 fn from_str(s: &str) -> Result<Self, Self::Err> {
569 match s {
570 "plain" => Ok(Self::Plain),
571 "S256" => Ok(Self::S256),
572 value => Ok(Self::Unknown(value.to_owned())),
573 }
574 }
575}
576
577impl<'de> serde::Deserialize<'de> for PkceCodeChallengeMethod {
578 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
579 where
580 D: serde::de::Deserializer<'de>,
581 {
582 let s = String::deserialize(deserializer)?;
583 core::str::FromStr::from_str(&s).map_err(serde::de::Error::custom)
584 }
585}
586
587impl serde::Serialize for PkceCodeChallengeMethod {
588 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
589 where
590 S: serde::ser::Serializer,
591 {
592 serializer.serialize_str(&self.to_string())
593 }
594}
595
596impl schemars::JsonSchema for PkceCodeChallengeMethod {
597 fn schema_name() -> String {
598 "PkceCodeChallengeMethod".to_owned()
599 }
600
601 fn json_schema(_gen: &mut schemars::r#gen::SchemaGenerator) -> schemars::schema::Schema {
602 let enums = vec![
603 schemars::schema::SchemaObject {
605 const_value: Some("plain".into()),
606 ..Default::default()
607 }
608 .into(),
609 schemars::schema::SchemaObject {
611 const_value: Some("S256".into()),
612 ..Default::default()
613 }
614 .into(),
615 ];
616
617 let description = r"PKCE Code Challenge Method";
618 schemars::schema::SchemaObject {
619 metadata: Some(Box::new(schemars::schema::Metadata {
620 description: Some(description.to_owned()),
621 ..Default::default()
622 })),
623 subschemas: Some(Box::new(schemars::schema::SubschemaValidation {
624 any_of: Some(enums),
625 ..Default::default()
626 })),
627 ..Default::default()
628 }
629 .into()
630 }
631}