changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > core / rust/lib/obj/src/config/auth.rs

changeset 698: 96958d3eb5b0
parent: 55fbe0e45b62
author: Richard Westhaver <ellis@rwest.io>
date: Fri, 04 Oct 2024 22:04:59 -0400
permissions: -rw-r--r--
description: fixes
1 //! Auth Configs
2 use serde::{Deserialize, Serialize};
3 
4 #[cfg(feature = "oauth")]
5 use yup_oauth2::ApplicationSecret;
6 
7 #[derive(Serialize, Deserialize, Debug, Default, Hash, Clone)]
8 pub struct AuthConfig {
9  pub provider: String,
10  #[cfg(feature = "oauth")]
11  pub oauth: Option<Oauth2Config>,
12  pub ssh: Option<SshConfig>,
13  pub pw: Option<PasswordConfig>,
14 }
15 
16 #[derive(Serialize, Deserialize, Default, Debug, Hash, Clone)]
17 pub struct PasswordConfig(String, String);
18 
19 #[cfg(feature = "oauth")]
20 #[derive(Serialize, Deserialize, Hash, Debug, PartialEq, Clone, Default)]
21 pub struct Oauth2Config {
22  pub client_id: String,
23  pub client_secret: String,
24  pub redirect_uris: Vec<String>,
25  pub auth_uri: String,
26  pub token_uri: String,
27  pub project_id: Option<String>, //for apptoken
28  pub client_email: Option<String>,
29  /// The URL of the public x509 certificate, used to verify the signature on
30  /// JWTs, such as ID tokens, signed by the authentication provider.
31  pub auth_provider_x509_cert_url: Option<String>,
32  /// The URL of the public x509 certificate, used to verify JWTs signed by
33  /// the client.
34  pub client_x509_cert_url: Option<String>,
35 }
36 
37 #[cfg(feature = "oauth")]
38 impl From<ApplicationSecret> for Oauth2Config {
39  fn from(shh: ApplicationSecret) -> Self {
40  Oauth2Config {
41  client_id: shh.client_id,
42  client_secret: shh.client_secret,
43  redirect_uris: shh.redirect_uris,
44  auth_uri: shh.auth_uri,
45  token_uri: shh.token_uri,
46  project_id: shh.project_id,
47  client_email: shh.client_email,
48  auth_provider_x509_cert_url: shh.auth_provider_x509_cert_url,
49  client_x509_cert_url: shh.client_x509_cert_url,
50  }
51  }
52 }
53 
54 #[cfg(feature = "oauth")]
55 impl From<Oauth2Config> for ApplicationSecret {
56  fn from(cfg: Oauth2Config) -> Self {
57  ApplicationSecret {
58  client_id: cfg.client_id,
59  client_secret: cfg.client_secret,
60  redirect_uris: cfg.redirect_uris,
61  auth_uri: cfg.auth_uri,
62  token_uri: cfg.token_uri,
63  project_id: cfg.project_id,
64  client_email: cfg.client_email,
65  auth_provider_x509_cert_url: cfg.auth_provider_x509_cert_url,
66  client_x509_cert_url: cfg.client_x509_cert_url,
67  }
68  }
69 }
70 
71 #[derive(Serialize, Deserialize, Hash, Debug, PartialEq, Clone, Default)]
72 pub struct SshConfig {}