mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-04 12:22:55 +00:00
chore: return authorize err msg to mysql client (#905)
chore: refine authorize err msg to client
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user