Skip to content

Commit

Permalink
Grant job permission for all roles except GUEST (vesoft-inc#2928)
Browse files Browse the repository at this point in the history
* Grant job permission for all roles except GUEST

* Split AdminShowjob from AdminJOb for permission control

Co-authored-by: CBS <[email protected]>
Co-authored-by: Doodle <[email protected]>
  • Loading branch information
3 people authored Sep 27, 2021
1 parent 073fb37 commit 7332381
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/graph/service/PermissionCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Status PermissionCheck::permissionCheck(ClientSession *session,
case Sentence::Kind::kAddHostIntoZone:
case Sentence::Kind::kDropHostFromZone:
case Sentence::Kind::kBalance:
case Sentence::Kind::kAdminJob:
case Sentence::Kind::kShowConfigs:
case Sentence::Kind::kSetConfig:
case Sentence::Kind::kGetConfig:
Expand Down Expand Up @@ -116,7 +115,8 @@ Status PermissionCheck::permissionCheck(ClientSession *session,
case Sentence::Kind::kUpdateEdge:
case Sentence::Kind::kDeleteVertices:
case Sentence::Kind::kDeleteTags:
case Sentence::Kind::kDeleteEdges: {
case Sentence::Kind::kDeleteEdges:
case Sentence::Kind::kAdminJob: {
return PermissionManager::canWriteData(session, vctx);
}
case Sentence::Kind::kDescribeTag:
Expand Down Expand Up @@ -153,7 +153,8 @@ Status PermissionCheck::permissionCheck(ClientSession *session,
case Sentence::Kind::kShowCreateTagIndex:
case Sentence::Kind::kShowCreateEdgeIndex:
case Sentence::Kind::kShowListener:
case Sentence::Kind::kShowFTIndexes: {
case Sentence::Kind::kShowFTIndexes:
case Sentence::Kind::kAdminShowJobs: {
/**
* Above operations can get the space id via session,
* so the permission same with canReadSchemaOrData.
Expand Down
1 change: 1 addition & 0 deletions src/graph/validator/Validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ std::unique_ptr<Validator> Validator::makeValidator(Sentence* sentence, QueryCon
case Sentence::Kind::kBalance:
return std::make_unique<BalanceValidator>(sentence, context);
case Sentence::Kind::kAdminJob:
case Sentence::Kind::kAdminShowJobs:
return std::make_unique<AdminJobValidator>(sentence, context);
case Sentence::Kind::kFetchVertices:
return std::make_unique<FetchVerticesValidator>(sentence, context);
Expand Down
6 changes: 5 additions & 1 deletion src/parser/AdminSentences.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,11 @@ class AdminJobSentence final : public Sentence {
explicit AdminJobSentence(meta::cpp2::AdminJobOp op,
meta::cpp2::AdminCmd cmd = meta::cpp2::AdminCmd::UNKNOWN)
: op_(op), cmd_(cmd) {
kind_ = Kind::kAdminJob;
if (op == meta::cpp2::AdminJobOp::SHOW || op == meta::cpp2::AdminJobOp::SHOW_All) {
kind_ = Kind::kAdminShowJobs;
} else {
kind_ = Kind::kAdminJob;
}
}

void addPara(const std::string& para);
Expand Down
1 change: 1 addition & 0 deletions src/parser/Sentence.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class Sentence {
kCreateSnapshot,
kDropSnapshot,
kAdminJob,
kAdminShowJobs,
kGetSubgraph,
kAddGroup,
kDropGroup,
Expand Down

0 comments on commit 7332381

Please sign in to comment.