Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql/examples/serve_auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl<W: io::Write + Send> AsyncMysqlShim<W> for Backend {
"mysql_native_password"
}

fn auth_plugin_for_username(&self, _user: &[u8]) -> &str {
async fn auth_plugin_for_username(&self, _user: &[u8]) -> &str {
"mysql_native_password"
}

Expand Down
12 changes: 8 additions & 4 deletions mysql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ pub use crate::resultset::{InitWriter, QueryResultWriter, RowWriter, StatementMe
pub use crate::value::{ToMysqlValue, Value, ValueInner};

const SCRAMBLE_SIZE: usize = 20;
const MYSQL_NATIVE_PASSWORD: &str = "mysql_native_password";

#[async_trait]
/// Implementors of this async-trait can be used to drive a MySQL-compatible database backend.
Expand All @@ -114,12 +115,12 @@ pub trait AsyncMysqlShim<W: Write + Send> {

/// get auth plugin
fn default_auth_plugin(&self) -> &str {
"mysql_native_password"
MYSQL_NATIVE_PASSWORD
}

/// get auth plugin
fn auth_plugin_for_username(&self, _user: &[u8]) -> &str {
"mysql_native_password"
async fn auth_plugin_for_username(&self, _user: &[u8]) -> &str {
MYSQL_NATIVE_PASSWORD
}

/// Default salt(scramble) for auth plugin
Expand Down Expand Up @@ -354,7 +355,10 @@ impl<B: AsyncMysqlShim<Cursor<Vec<u8>>> + Send + Sync, S: AsyncRead + AsyncWrite

self.client_capabilities = handshake.capabilities;
let mut auth_response = handshake.auth_response.clone();
let auth_plugin_expect = self.shim.auth_plugin_for_username(&handshake.username);
let auth_plugin_expect = self
.shim
.auth_plugin_for_username(&handshake.username)
.await;

// auth switch
if !auth_plugin_expect.is_empty()
Expand Down