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