@@ -9,7 +9,7 @@ use camino::{Utf8Path, Utf8PathBuf};
99use cfg_if:: cfg_if;
1010use picky:: key:: { PrivateKey , PublicKey } ;
1111use picky:: pem:: Pem ;
12- use secrecy:: SecretString ;
12+ use secrecy:: { ExposeSecret as _ , SecretString } ;
1313use tap:: prelude:: * ;
1414use tokio:: sync:: Notify ;
1515use tokio_rustls:: rustls:: pki_types;
@@ -197,7 +197,7 @@ pub struct Conf {
197197 pub debug : dto:: DebugConf ,
198198}
199199
200- #[ derive( PartialEq , Debug , Clone ) ]
200+ #[ derive( Debug , Clone ) ]
201201pub struct WebAppConf {
202202 pub enabled : bool ,
203203 pub authentication : WebAppAuth ,
@@ -206,13 +206,13 @@ pub struct WebAppConf {
206206 pub static_root_path : std:: path:: PathBuf ,
207207}
208208
209- #[ derive( PartialEq , Eq , Debug , Clone ) ]
209+ #[ derive( Debug , Clone ) ]
210210pub enum WebAppAuth {
211211 Custom ( HashMap < String , WebAppUser > ) ,
212212 None ,
213213}
214214
215- #[ derive( PartialEq , Eq , Debug , Clone ) ]
215+ #[ derive( Debug , Clone ) ]
216216pub struct WebAppUser {
217217 pub name : String ,
218218 /// Hash of the password, in the PHC string format
@@ -1256,7 +1256,8 @@ fn read_pfx_file(
12561256 use picky:: x509:: certificate:: CertType ;
12571257
12581258 let crypto_context = password
1259- . map ( |pwd| Pkcs12CryptoContext :: new_with_password ( pwd. expose_secret ( ) ) )
1259+ . map ( |secret| secret. expose_secret ( ) )
1260+ . map ( Pkcs12CryptoContext :: new_with_password)
12601261 . unwrap_or_else ( Pkcs12CryptoContext :: new_without_password) ;
12611262 let parsing_params = Pkcs12ParsingParams :: default ( ) ;
12621263
@@ -1577,6 +1578,8 @@ fn to_listener_urls(conf: &dto::ListenerConf, hostname: &str, auto_ipv6: bool) -
15771578pub mod dto {
15781579 use std:: collections:: HashMap ;
15791580
1581+ use secrecy:: ExposeSecret as _;
1582+
15801583 use super :: * ;
15811584
15821585 /// Source of truth for Gateway configuration
@@ -1585,7 +1588,7 @@ pub mod dto {
15851588 /// and is not trying to be too smart.
15861589 ///
15871590 /// Unstable options are subject to change
1588- #[ derive( PartialEq , Debug , Clone , Serialize , Deserialize ) ]
1591+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
15891592 #[ serde( rename_all = "PascalCase" ) ]
15901593 pub struct ConfFile {
15911594 /// This Gateway unique ID (e.g.: 123e4567-e89b-12d3-a456-426614174000)
@@ -1626,7 +1629,10 @@ pub mod dto {
16261629 #[ serde( alias = "PrivateKeyFile" , skip_serializing_if = "Option::is_none" ) ]
16271630 pub tls_private_key_file : Option < Utf8PathBuf > ,
16281631 /// Password to use for decrypting the TLS private key
1629- #[ serde( skip_serializing_if = "Option::is_none" ) ]
1632+ #[ serde(
1633+ skip_serializing_if = "Option::is_none" ,
1634+ serialize_with = "serialize_opt_secret_string"
1635+ ) ]
16301636 pub tls_private_key_password : Option < SecretString > ,
16311637 /// Subject name of the certificate to use for TLS
16321638 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -1661,8 +1667,11 @@ pub mod dto {
16611667 pub credssp_private_key_file : Option < Utf8PathBuf > ,
16621668
16631669 /// Password to use for decrypting the CredSSP private key
1664- #[ serde( skip_serializing_if = "Option::is_none" ) ]
1665- pub credssp_private_key_password : Option < Password > ,
1670+ #[ serde(
1671+ skip_serializing_if = "Option::is_none" ,
1672+ serialize_with = "serialize_opt_secret_string"
1673+ ) ]
1674+ pub credssp_private_key_password : Option < SecretString > ,
16661675
16671676 /// Listeners to launch at startup
16681677 #[ serde( default , skip_serializing_if = "Vec::is_empty" ) ]
@@ -1811,15 +1820,16 @@ pub mod dto {
18111820 }
18121821
18131822 /// Domain user credentials.
1814- #[ derive( PartialEq , Eq , Debug , Clone , Serialize , Deserialize ) ]
1823+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
18151824 pub struct DomainUser {
18161825 /// Username in FQDN format (e.g. "pw13@example.com").
18171826 ///
18181827 /// **Note**: the user's domain part must match the internal KDC realm.
18191828 /// The KDC realm is derived from the gateway ID using the [KerberosServer::realm] method.
18201829 pub fqdn : String ,
18211830 /// User password.
1822- pub password : String ,
1831+ #[ serde( serialize_with = "serialize_secret_string" ) ]
1832+ pub password : SecretString ,
18231833 /// Salt for generating the user's key.
18241834 ///
18251835 /// Usually, it is equal to `{REALM}{username}` (e.g. "EXAMPLEpw13").
@@ -1832,7 +1842,7 @@ pub mod dto {
18321842
18331843 Self {
18341844 username : fqdn,
1835- password,
1845+ password : password . expose_secret ( ) . to_owned ( ) ,
18361846 salt,
18371847 }
18381848 }
@@ -1841,7 +1851,7 @@ pub mod dto {
18411851 /// Kerberos server config
18421852 ///
18431853 /// This config is used to configure the Kerberos server during RDP proxying.
1844- #[ derive( PartialEq , Eq , Debug , Clone , Serialize , Deserialize ) ]
1854+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
18451855 pub struct KerberosServer {
18461856 /// Users credentials inside fake KDC.
18471857 pub users : Vec < DomainUser > ,
@@ -1896,7 +1906,7 @@ pub mod dto {
18961906 }
18971907
18981908 /// The Kerberos credentials-injection configuration.
1899- #[ derive( PartialEq , Eq , Debug , Clone , Serialize , Deserialize ) ]
1909+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
19001910 pub struct KerberosConfig {
19011911 /// Kerberos server and KDC configuration.
19021912 pub kerberos_server : KerberosServer ,
@@ -1910,7 +1920,7 @@ pub mod dto {
19101920 ///
19111921 /// Note to developers: all options should be safe by default, never add an option
19121922 /// that needs to be overridden manually in order to be safe.
1913- #[ derive( PartialEq , Eq , Debug , Clone , Serialize , Deserialize ) ]
1923+ #[ derive( Debug , Clone , Serialize , Deserialize ) ]
19141924 pub struct DebugConf {
19151925 /// Dump received tokens using a `debug` statement
19161926 #[ serde( default ) ]
@@ -1974,7 +1984,15 @@ pub mod dto {
19741984
19751985 impl DebugConf {
19761986 pub fn is_default ( & self ) -> bool {
1977- Self :: default ( ) . eq ( self )
1987+ !self . dump_tokens
1988+ && !self . disable_token_validation
1989+ && self . override_kdc . is_none ( )
1990+ && self . log_directives . is_none ( )
1991+ && self . capture_path . is_none ( )
1992+ && self . lib_xmf_path . is_none ( )
1993+ && !self . enable_unstable
1994+ && self . kerberos . is_none ( )
1995+ && self . ws_keep_alive_interval == ws_keep_alive_interval_default_value ( )
19781996 }
19791997 }
19801998
@@ -2355,6 +2373,23 @@ pub mod dto {
23552373 }
23562374 }
23572375
2376+ fn serialize_secret_string < S > ( value : & SecretString , serializer : S ) -> Result < S :: Ok , S :: Error >
2377+ where
2378+ S : serde:: Serializer ,
2379+ {
2380+ serializer. serialize_str ( value. expose_secret ( ) )
2381+ }
2382+
2383+ fn serialize_opt_secret_string < S > ( value : & Option < SecretString > , serializer : S ) -> Result < S :: Ok , S :: Error >
2384+ where
2385+ S : serde:: Serializer ,
2386+ {
2387+ match value {
2388+ Some ( s) => serializer. serialize_str ( s. expose_secret ( ) ) ,
2389+ None => serializer. serialize_none ( ) ,
2390+ }
2391+ }
2392+
23582393 impl ProxyConf {
23592394 /// Convert this DTO to the http-client-proxy ProxyConfig.
23602395 pub fn to_proxy_config ( & self ) -> http_client_proxy:: ProxyConfig {
0 commit comments