@@ -410,6 +410,17 @@ pub(crate) struct MysqlOpts {
410
410
/// Changes the behavior of the affected count returned for writes (UPDATE/INSERT etc).
411
411
/// It makes MySQL return the FOUND rows instead of the AFFECTED rows.
412
412
client_found_rows : bool ,
413
+
414
+ /// Enables Client-Side Cleartext Pluggable Authentication (defaults to `false`).
415
+ ///
416
+ /// Enables client to send passwords to the server as cleartext, without hashing or encryption
417
+ /// (consult MySql documentation for more info).
418
+ ///
419
+ /// # Security Notes
420
+ ///
421
+ /// Sending passwords as cleartext may be a security problem in some configurations. Please
422
+ /// consider using TLS or encrypted tunnels for server connection.
423
+ enable_cleartext_plugin : bool ,
413
424
}
414
425
415
426
/// Mysql connection options.
@@ -747,6 +758,31 @@ impl Opts {
747
758
self . inner . mysql_opts . client_found_rows
748
759
}
749
760
761
+ /// Returns `true` if `mysql_clear_password` plugin support is enabled (defaults to `false`).
762
+ ///
763
+ /// `mysql_clear_password` enables client to send passwords to the server as cleartext, without
764
+ /// hashing or encryption (consult MySql documentation for more info).
765
+ ///
766
+ /// # Security Notes
767
+ ///
768
+ /// Sending passwords as cleartext may be a security problem in some configurations. Please
769
+ /// consider using TLS or encrypted tunnels for server connection.
770
+ ///
771
+ /// # Connection URL
772
+ ///
773
+ /// Use `enable_cleartext_plugin` URL parameter to set this value. E.g.
774
+ ///
775
+ /// ```
776
+ /// # use mysql_async::*;
777
+ /// # fn main() -> Result<()> {
778
+ /// let opts = Opts::from_url("mysql://localhost/db?enable_cleartext_plugin=true")?;
779
+ /// assert!(opts.enable_cleartext_plugin());
780
+ /// # Ok(()) }
781
+ /// ```
782
+ pub fn enable_cleartext_plugin ( & self ) -> bool {
783
+ self . inner . mysql_opts . enable_cleartext_plugin
784
+ }
785
+
750
786
pub ( crate ) fn get_capabilities ( & self ) -> CapabilityFlags {
751
787
let mut out = CapabilityFlags :: CLIENT_PROTOCOL_41
752
788
| CapabilityFlags :: CLIENT_SECURE_CONNECTION
@@ -797,6 +833,7 @@ impl Default for MysqlOpts {
797
833
wait_timeout : None ,
798
834
secure_auth : true ,
799
835
client_found_rows : false ,
836
+ enable_cleartext_plugin : false ,
800
837
}
801
838
}
802
839
}
@@ -1053,6 +1090,32 @@ impl OptsBuilder {
1053
1090
self . opts . client_found_rows = client_found_rows;
1054
1091
self
1055
1092
}
1093
+
1094
+ /// Enables Client-Side Cleartext Pluggable Authentication (defaults to `false`).
1095
+ ///
1096
+ /// Enables client to send passwords to the server as cleartext, without hashing or encryption
1097
+ /// (consult MySql documentation for more info).
1098
+ ///
1099
+ /// # Security Notes
1100
+ ///
1101
+ /// Sending passwords as cleartext may be a security problem in some configurations. Please
1102
+ /// consider using TLS or encrypted tunnels for server connection.
1103
+ ///
1104
+ /// # Connection URL
1105
+ ///
1106
+ /// Use `enable_cleartext_plugin` URL parameter to set this value. E.g.
1107
+ ///
1108
+ /// ```
1109
+ /// # use mysql_async::*;
1110
+ /// # fn main() -> Result<()> {
1111
+ /// let opts = Opts::from_url("mysql://localhost/db?enable_cleartext_plugin=true")?;
1112
+ /// assert!(opts.enable_cleartext_plugin());
1113
+ /// # Ok(()) }
1114
+ /// ```
1115
+ pub fn enable_cleartext_plugin ( mut self , enable_cleartext_plugin : bool ) -> Self {
1116
+ self . opts . enable_cleartext_plugin = enable_cleartext_plugin;
1117
+ self
1118
+ }
1056
1119
}
1057
1120
1058
1121
impl From < OptsBuilder > for Opts {
@@ -1235,6 +1298,16 @@ fn mysqlopts_from_url(url: &Url) -> std::result::Result<MysqlOpts, UrlError> {
1235
1298
} ) ;
1236
1299
}
1237
1300
}
1301
+ } else if key == "enable_cleartext_plugin" {
1302
+ match bool:: from_str ( & * value) {
1303
+ Ok ( parsed) => opts. enable_cleartext_plugin = parsed,
1304
+ Err ( _) => {
1305
+ return Err ( UrlError :: InvalidParamValue {
1306
+ param : key. to_string ( ) ,
1307
+ value,
1308
+ } ) ;
1309
+ }
1310
+ }
1238
1311
} else if key == "tcp_nodelay" {
1239
1312
match bool:: from_str ( & * value) {
1240
1313
Ok ( value) => opts. tcp_nodelay = value,
0 commit comments