提交 1504a965 编写于 作者: F Fankux

judge sys tenant when auth

上级 0f647e8e
......@@ -174,7 +174,8 @@ int ObAccess::init(const OblogConfig& hs_config)
int ObAccess::auth()
{
for (auto& server : _servers) {
int ret = _table_whites.all_tenant ? auth_sys(server) : auth_tenant(server);
bool auth_by_sys = _table_whites.all_tenant || _table_whites.with_sys;
int ret = auth_by_sys ? auth_sys(server) : auth_tenant(server);
if (ret != OMS_OK) {
return OMS_FAILED;
}
......@@ -201,7 +202,7 @@ int ObAccess::auth_sys(const ServerInfo& server)
const MySQLRow& row = rs.rows.front();
const std::string& tenant = row.fields().front();
if (tenant.size() < 3 || strncasecmp("sys", tenant.c_str(), 3) != 0) {
OMS_ERROR << "Failed to auth, all tenant mode must be sys tenant, current: " << tenant;
OMS_ERROR << "Failed to auth, all tenant mode or sys tenant must be connected as sys tenant, current: " << tenant;
return OMS_FAILED;
}
return OMS_OK;
......
......@@ -113,7 +113,11 @@ int TenantDbTable::from(const std::string& table_whites)
}
const std::string& tenant = items[0];
if (tenant == "sys") {
with_sys = true;
}
if (tenant == "*") {
with_sys = true;
all_tenant = true;
tenants.clear();
return OMS_OK;
......
......@@ -60,6 +60,7 @@ struct DbTable {
};
struct TenantDbTable {
bool with_sys = false;
bool all_tenant = false;
std::map<std::string, DbTable> tenants;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册