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