Skip to content

Commit adc4da7

Browse files
authored
KIKIMR-20081: add grant/revoke permissions to query service (#522)
* add grant/revore permissions to query service * fix rebase * fix issues
1 parent 530fde1 commit adc4da7

17 files changed

+484
-162
lines changed

ydb/core/kqp/executer_actor/kqp_scheme_executer.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -166,31 +166,37 @@ class TKqpSchemeExecuter : public TActorBootstrapped<TKqpSchemeExecuter> {
166166
}
167167

168168
case NKqpProto::TKqpSchemeOperation::kCreateGroup: {
169-
auto modifyScheme = schemeOp.GetCreateGroup();
169+
const auto& modifyScheme = schemeOp.GetCreateGroup();
170170
ev->Record.MutableTransaction()->MutableModifyScheme()->CopyFrom(modifyScheme);
171171
break;
172172
}
173173

174174
case NKqpProto::TKqpSchemeOperation::kAddGroupMembership: {
175-
auto modifyScheme = schemeOp.GetAddGroupMembership();
175+
const auto& modifyScheme = schemeOp.GetAddGroupMembership();
176176
ev->Record.MutableTransaction()->MutableModifyScheme()->CopyFrom(modifyScheme);
177177
break;
178178
}
179179

180180
case NKqpProto::TKqpSchemeOperation::kRemoveGroupMembership: {
181-
auto modifyScheme = schemeOp.GetRemoveGroupMembership();
181+
const auto& modifyScheme = schemeOp.GetRemoveGroupMembership();
182182
ev->Record.MutableTransaction()->MutableModifyScheme()->CopyFrom(modifyScheme);
183183
break;
184184
}
185185

186186
case NKqpProto::TKqpSchemeOperation::kRenameGroup: {
187-
auto modifyScheme = schemeOp.GetRenameGroup();
187+
const auto& modifyScheme = schemeOp.GetRenameGroup();
188188
ev->Record.MutableTransaction()->MutableModifyScheme()->CopyFrom(modifyScheme);
189189
break;
190190
}
191191

192192
case NKqpProto::TKqpSchemeOperation::kDropGroup: {
193-
auto modifyScheme = schemeOp.GetDropGroup();
193+
const auto& modifyScheme = schemeOp.GetDropGroup();
194+
ev->Record.MutableTransaction()->MutableModifyScheme()->CopyFrom(modifyScheme);
195+
break;
196+
}
197+
198+
case NKqpProto::TKqpSchemeOperation::kModifyPermissions: {
199+
const auto& modifyScheme = schemeOp.GetModifyPermissions();
194200
ev->Record.MutableTransaction()->MutableModifyScheme()->CopyFrom(modifyScheme);
195201
break;
196202
}

ydb/core/kqp/gateway/kqp_ic_gateway.cpp

+9-17
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,8 @@ namespace {
688688
};
689689

690690
struct TModifyPermissionsWrapper : public TThrRefBase {
691-
using TMethod = std::function<void(NYql::TModifyPermissionsSettings::EAction action, THashSet<TString>&& permissions, THashSet<TString>&& roles, TVector<TString>&& pathes)>;
692-
TMethod ModifyPermissionsForPathes;
691+
using TMethod = std::function<void(NYql::TModifyPermissionsSettings::EAction action, THashSet<TString>&& permissions, THashSet<TString>&& roles, TVector<TString>&& paths)>;
692+
TMethod ModifyPermissionsForPaths;
693693
};
694694
}
695695

@@ -1275,18 +1275,18 @@ class TKikimrIcGateway : public IKqpGateway {
12751275
return MakeFuture(ResultFromError<TGenericResult>("No permissions names for modify permissions"));
12761276
}
12771277

1278-
if (settings.Pathes.empty()) {
1279-
return MakeFuture(ResultFromError<TGenericResult>("No pathes for modify permissions"));
1278+
if (settings.Paths.empty()) {
1279+
return MakeFuture(ResultFromError<TGenericResult>("No paths for modify permissions"));
12801280
}
12811281

12821282
if (settings.Roles.empty()) {
12831283
return MakeFuture(ResultFromError<TGenericResult>("No roles for modify permissions"));
12841284
}
12851285

12861286
TVector<TPromise<TGenericResult>> promises;
1287-
promises.reserve(settings.Pathes.size());
1287+
promises.reserve(settings.Paths.size());
12881288
TVector<TFuture<TGenericResult>> futures;
1289-
futures.reserve(settings.Pathes.size());
1289+
futures.reserve(settings.Paths.size());
12901290

12911291
NACLib::TDiffACL acl;
12921292
switch (settings.Action) {
@@ -1322,9 +1322,9 @@ class TKikimrIcGateway : public IKqpGateway {
13221322
const auto serializedDiffAcl = acl.SerializeAsString();
13231323

13241324
TVector<std::pair<const TString*, std::pair<TString, TString>>> pathPairs;
1325-
pathPairs.reserve(settings.Pathes.size());
1326-
for (const auto& path : settings.Pathes) {
1327-
pathPairs.push_back(std::make_pair(&path, SplitPathByDirAndBaseNames(path)));
1325+
pathPairs.reserve(settings.Paths.size());
1326+
for (const auto& path : settings.Paths) {
1327+
pathPairs.push_back(std::make_pair(&path, NSchemeHelpers::SplitPathByDirAndBaseNames(path)));
13281328
}
13291329

13301330
for (const auto& path : pathPairs) {
@@ -2311,14 +2311,6 @@ class TKikimrIcGateway : public IKqpGateway {
23112311
}
23122312

23132313
private:
2314-
static std::pair<TString, TString> SplitPathByDirAndBaseNames(const TString& path) {
2315-
auto splitPos = path.find_last_of('/');
2316-
if (splitPos == path.npos || splitPos + 1 == path.size()) {
2317-
ythrow yexception() << "wrong path format '" << path << "'" ;
2318-
}
2319-
return {path.substr(0, splitPos), path.substr(splitPos + 1)};
2320-
}
2321-
23222314
static TListPathResult GetListPathResult(const TPathDescription& pathDesc, const TString& path) {
23232315
if (pathDesc.GetSelf().GetPathType() != EPathTypeDir) {
23242316
return ResultFromError<TListPathResult>(TString("Directory not found: ") + path);

ydb/core/kqp/gateway/utils/scheme_helpers.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,12 @@ void FillCreateExternalTableColumnDesc(NKikimrSchemeOp::TExternalTableDescriptio
8686
externalTableDesc.SetContent(general.SerializeAsString());
8787
}
8888

89+
std::pair<TString, TString> SplitPathByDirAndBaseNames(const TString& path) {
90+
auto splitPos = path.find_last_of('/');
91+
if (splitPos == path.npos || splitPos + 1 == path.size()) {
92+
ythrow yexception() << "wrong path format '" << path << "'";
93+
}
94+
return {path.substr(0, splitPos), path.substr(splitPos + 1)};
95+
}
96+
8997
} // namespace NKikimr::NKqp::NSchemeHelpers

ydb/core/kqp/gateway/utils/scheme_helpers.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ void FillCreateExternalTableColumnDesc(NKikimrSchemeOp::TExternalTableDescriptio
3131
const TString& name,
3232
const NYql::TCreateExternalTableSettings& settings);
3333

34+
std::pair<TString, TString> SplitPathByDirAndBaseNames(const TString& path);
35+
3436
} // namespace NKikimr::NKqp::NSchemeHelpers

0 commit comments

Comments
 (0)