chore: return authorize err msg to mysql client (#905)

chore: refine authorize err msg to client
This commit is contained in:
shuiyisong
2023-01-29 10:53:36 +08:00
committed by GitHub
parent ae8afd3711
commit 637837ae44
2 changed files with 12 additions and 4 deletions

View File

@@ -110,7 +110,7 @@ pub enum Error {
UserPasswordMismatch { username: String },
#[snafu(display(
"User {} is not allowed to access catalog {} and schema {}",
"Access denied for user '{}' to database '{}-{}'",
username,
catalog,
schema

View File

@@ -190,10 +190,18 @@ impl<W: AsyncWrite + Send + Sync + Unpin> AsyncMysqlShim<W> for MysqlInstanceShi
error::DatabaseNotFoundSnafu { catalog, schema }
);
let user_info = &self.session.user_info();
if let Some(schema_validator) = &self.user_provider {
schema_validator
.authorize(catalog, schema, &self.session.user_info())
.await?;
if let Err(e) = schema_validator.authorize(catalog, schema, user_info).await {
return w
.error(
ErrorKind::ER_DBACCESS_DENIED_ERROR,
e.to_string().as_bytes(),
)
.await
.map_err(|e| e.into());
}
}
let context = self.session.context();