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

User manager for graph layer #1842

Merged
merged 6 commits into from
Mar 11, 2020
Merged

User manager for graph layer #1842

merged 6 commits into from
Mar 11, 2020

Conversation

bright-starry-sky
Copy link
Contributor

User manager for graph layer.

src/graph/ShowExecutor.cpp Outdated Show resolved Hide resolved
src/graph/ShowExecutor.cpp Outdated Show resolved Hide resolved
src/parser/parser.yy Outdated Show resolved Hide resolved
src/parser/UserSentences.h Outdated Show resolved Hide resolved
src/graph/UserExecutor.cpp Show resolved Hide resolved
src/graph/UserExecutor.cpp Outdated Show resolved Hide resolved
src/graph/UserExecutor.cpp Outdated Show resolved Hide resolved
src/graph/ShowExecutor.cpp Show resolved Hide resolved
src/graph/ShowExecutor.cpp Outdated Show resolved Hide resolved
src/graph/UserExecutor.cpp Show resolved Hide resolved
@ansarizafar
Copy link

Its better to use term Super Admin/User than GOD.

@jude-zhu jude-zhu added this to the R201910_RC4 milestone Mar 3, 2020
liuyu85cn
liuyu85cn previously approved these changes Mar 6, 2020
Copy link
Contributor

@liuyu85cn liuyu85cn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

src/graph/UserExecutor.cpp Outdated Show resolved Hide resolved
src/graph/UserExecutor.cpp Outdated Show resolved Hide resolved
@panda-sheep
Copy link
Contributor

Great job, LGTM
Please resolve the conflict first

panda-sheep
panda-sheep previously approved these changes Mar 6, 2020
Copy link
Contributor

@panda-sheep panda-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, 👍

@@ -157,6 +153,15 @@ SNAPSHOT ([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])
SNAPSHOTS ([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt][Ss])
FORCE ([Ff][Oo][Rr][Cc][Ee])
BIDIRECT ([Bb][Ii][Dd][Ii][Rr][Ee][Cc][Tt])
MAX_QUERIES_PER_HOUR ([Mm][Aa][Xx][_][Qq][Uu][Ee][Rr][Ii][Ee][Ss][_][Pp][Ee][Rr][_][Hh][Oo][Uu][Rr])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we don't need them anymore.

@@ -429,6 +421,26 @@ TEST(Scanner, Basic) {
CHECK_SEMANTIC_TYPE("SNAPSHOTS", TokenType::KW_SNAPSHOTS),
CHECK_SEMANTIC_TYPE("Snapshots", TokenType::KW_SNAPSHOTS),
CHECK_SEMANTIC_TYPE("snapshots", TokenType::KW_SNAPSHOTS),
CHECK_SEMANTIC_TYPE("MAX_QUERIES_PER_HOUR", TokenType::KW_MAX_QUERIES_PER_HOUR),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

// encoded password
4: optional string encoded_pwd,
// The number of queries an account can issue per hour
5: optional i32 max_queries_per_hour,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need them any more before we don't implement user's isolation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need them any more before we don't implement user's isolation.

Good suggest !
Yes , They are useless here if we don't implement user's isolation.
I also hesitated to add these options at that time. Now, let me delete them.

}

struct UserItem {
1: required string account;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have id for user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have id for user?

I've removed user id . because we can using user name to keep the uniqueness for users.


struct RoleItem {
1: string user,
2: string space,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use spaceId

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

fixed.

return;
}
if (roleItem.get_role_type() == nebula::cpp2::RoleType::GOD) {
spaceId = kDefaultSpaceId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support to grant a user to be GOD?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we support to grant a user to be GOD?

Only supported to grant a user to GOD in initialization phase.
We need to initialize a root user before the authority flag turn on.

src/interface/common.thrift Show resolved Hide resolved
if (!ret.ok()) {
if (req.get_missing_ok()) {
if (req.get_if_exists()) {
handleErrorCode(cpp2::ErrorCode::SUCCEEDED);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please recheck "handleErrorCode", IIRC "onFinished" has been called inside?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please recheck "handleErrorCode", IIRC "onFinished" has been called inside?

emm... seems It's works well now, "onFinished" have not call "handleErrorCode" inside.

return Status::OK();
}

void ChangePasswordExecutor::execute() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need "change password" Or just "resetPassword" ?

std::string MetaServiceUtils::replaceUserVal(const nebula::cpp2::UserItem& user,
folly::StringPiece val) {
nebula::cpp2::UserItem oldUser;
apache::thrift::CompactSerializer::deserialize(val, oldUser);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not serialize the newUser and overwrite the old one directly

@bright-starry-sky
Copy link
Contributor Author

Refactored root user initialize logic. Now we have only one super user naming "root".
metad will check the root user when meta service start. and then create the user if dose not exists .

src/meta/RootUserMan.h Show resolved Hide resolved
@@ -43,7 +43,19 @@ void DropSpaceProcessor::process(const cpp2::DropSpaceReq& req) {
deleteKeys.emplace_back(MetaServiceUtils::spaceKey(spaceId));

// delete related role data.
// TODO(boshengchen) delete related role data under the space
auto rolePrefix = MetaServiceUtils::roleSpacePrefix(spaceId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some LOGs when deleting the users information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add some LOGs when deleting the users information.

fixed.

@@ -145,26 +129,6 @@ struct HostItem {
4: map<string, list<common.PartitionID>> (cpp.template = "std::unordered_map") all_parts,
}

struct UserItem {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need it any more?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need it any more, currently we only have one item of password, we can storage it direct.
If there are new elements in the future, we can add this struct at that time.

Copy link
Contributor

@dangleptr dangleptr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally LGTM

/**
* Only leader part needed.
*/
auto ret = kvstore->partLeader(nebula::meta::kDefaultSpaceId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the logic on real cluster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the logic on real cluster

Yes, I've simple tested two meta nodes on virtual machines.
I will do complete integration test at later.

Copy link
Contributor

@panda-sheep panda-sheep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent!

@dangleptr dangleptr merged commit 70f14b2 into vesoft-inc:master Mar 11, 2020
@bright-starry-sky bright-starry-sky deleted the user_graph branch March 11, 2020 07:13
LOG(ERROR) << "Create User Failed :" << user.get_account() << " have existed";
handleErrorCode(cpp2::ErrorCode::E_EXISTED);
LOG(ERROR) << "Create User Failed : User " << account
<< " have existed!";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already existed.

tong-hao pushed a commit to tong-hao/nebula that referenced this pull request Jun 1, 2021
yixinglu pushed a commit to yixinglu/nebula that referenced this pull request Jan 31, 2023
* push filter down traverse rule

* fix conflicts

* fix tck

* fix exists func

Co-authored-by: jie.wang <38901892+jievince@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants