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