1.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2+++ b/obj/src/auth.rs Sun May 14 21:27:04 2023 -0400
1.3@@ -0,0 +1,72 @@
1.4+//! Auth Configs
1.5+use serde::{Deserialize, Serialize};
1.6+
1.7+#[cfg(feature = "oauth")]
1.8+use yup_oauth2::ApplicationSecret;
1.9+
1.10+#[derive(Serialize, Deserialize, Debug, Default, Hash)]
1.11+pub struct AuthConfig {
1.12+ pub provider: String,
1.13+ #[cfg(feature = "oauth")]
1.14+ pub oauth: Option<Oauth2Config>,
1.15+ pub ssh: Option<SshConfig>,
1.16+ pub pw: Option<PasswordConfig>,
1.17+}
1.18+
1.19+#[derive(Serialize, Deserialize, Default, Debug, Hash)]
1.20+pub struct PasswordConfig(String, String);
1.21+
1.22+#[cfg(feature = "oauth")]
1.23+#[derive(Serialize, Deserialize, Hash, Debug, PartialEq, Clone, Default)]
1.24+pub struct Oauth2Config {
1.25+ pub client_id: String,
1.26+ pub client_secret: String,
1.27+ pub redirect_uris: Vec<String>,
1.28+ pub auth_uri: String,
1.29+ pub token_uri: String,
1.30+ pub project_id: Option<String>, //for apptoken
1.31+ pub client_email: Option<String>,
1.32+ /// The URL of the public x509 certificate, used to verify the signature on
1.33+ /// JWTs, such as ID tokens, signed by the authentication provider.
1.34+ pub auth_provider_x509_cert_url: Option<String>,
1.35+ /// The URL of the public x509 certificate, used to verify JWTs signed by the
1.36+ /// client.
1.37+ pub client_x509_cert_url: Option<String>,
1.38+}
1.39+
1.40+#[cfg(feature = "oauth")]
1.41+impl From<ApplicationSecret> for Oauth2Config {
1.42+ fn from(shh: ApplicationSecret) -> Self {
1.43+ Oauth2Config {
1.44+ client_id: shh.client_id,
1.45+ client_secret: shh.client_secret,
1.46+ redirect_uris: shh.redirect_uris,
1.47+ auth_uri: shh.auth_uri,
1.48+ token_uri: shh.token_uri,
1.49+ project_id: shh.project_id,
1.50+ client_email: shh.client_email,
1.51+ auth_provider_x509_cert_url: shh.auth_provider_x509_cert_url,
1.52+ client_x509_cert_url: shh.client_x509_cert_url,
1.53+ }
1.54+ }
1.55+}
1.56+
1.57+#[cfg(feature = "oauth")]
1.58+impl From<Oauth2Config> for ApplicationSecret {
1.59+ fn from(cfg: Oauth2Config) -> Self {
1.60+ ApplicationSecret {
1.61+ client_id: cfg.client_id,
1.62+ client_secret: cfg.client_secret,
1.63+ redirect_uris: cfg.redirect_uris,
1.64+ auth_uri: cfg.auth_uri,
1.65+ token_uri: cfg.token_uri,
1.66+ project_id: cfg.project_id,
1.67+ client_email: cfg.client_email,
1.68+ auth_provider_x509_cert_url: cfg.auth_provider_x509_cert_url,
1.69+ client_x509_cert_url: cfg.client_x509_cert_url,
1.70+ }
1.71+ }
1.72+}
1.73+
1.74+#[derive(Serialize, Deserialize, Hash, Debug, PartialEq, Clone, Default)]
1.75+pub struct SshConfig {}