Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved customer friendliness for user permission. #1980

Merged
merged 2 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions src/common/base/Status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ std::string Status::toString() const {
case kPermissionError:
str = "PermissionError: ";
break;
case kSpaceNotFound:
str = "Space not found";
break;
default:
snprintf(tmp, sizeof(tmp), "Unknown error(%hu): ", static_cast<uint16_t>(code()));
str = tmp;
Expand Down
2 changes: 1 addition & 1 deletion src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum ErrorCode {

// Authentication Failure
E_INVALID_PASSWORD = -41,
E_INPROPER_ROLE = -42,
E_IMPROPER_ROLE = -42,
E_INVALID_PARTITION_NUM = -43,
E_INVALID_REPLICA_FACTOR = -44,
E_INVALID_CHARSET = -45,
Expand Down
4 changes: 4 additions & 0 deletions src/meta/client/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ Status MetaClient::handleResponse(const RESP& resp) {
return Status::Error("No valid collate");
case cpp2::ErrorCode::E_CHARSET_COLLATE_NOT_MATCH:
return Status::Error("Charset and collate not match");
case cpp2::ErrorCode::E_INVALID_PASSWORD:
return Status::Error("Invalid password");
case cpp2::ErrorCode::E_IMPROPER_ROLE:
return Status::Error("Improper role");
default:
return Status::Error("Unknown code %d", static_cast<int32_t>(resp.get_code()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/usersMan/AuthenticationProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void RevokeProcessor::process(const cpp2::RevokeRoleReq& req) {
auto val = result.value();
const auto role = *reinterpret_cast<const nebula::cpp2::RoleType *>(val.c_str());
if (role != roleItem.get_role_type()) {
handleErrorCode(cpp2::ErrorCode::E_INPROPER_ROLE);
handleErrorCode(cpp2::ErrorCode::E_IMPROPER_ROLE);
onFinished();
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/meta/test/AuthProcessorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ TEST(AuthProcessorTest, GrantRevokeTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(cpp2::ErrorCode::E_INPROPER_ROLE, resp.get_code());
ASSERT_EQ(cpp2::ErrorCode::E_IMPROPER_ROLE, resp.get_code());
}
// actual role is GUEST, but revoke unknown, expect error.
{
Expand All @@ -398,7 +398,7 @@ TEST(AuthProcessorTest, GrantRevokeTest) {
auto f = processor->getFuture();
processor->process(req);
auto resp = std::move(f).get();
ASSERT_EQ(cpp2::ErrorCode::E_INPROPER_ROLE, resp.get_code());
ASSERT_EQ(cpp2::ErrorCode::E_IMPROPER_ROLE, resp.get_code());
}
// revoke
{
Expand Down