Skip to content

Commit 47bf59d

Browse files
authored
security: add mode to restrict local user administration to admins (#14494)
Feature flag `enable_strict_user_management` restricts administration of local users and groups to subjects with administration access level. Administration access level belongs to cluster admins (members of the `administration_allowed_sids`) and also, if enabled, to database admins (owners of a database). Feature flag `enable_database_admin` enables database admins as a concept. Also allow admins to change ownership of the schema objects.
1 parent 79f6400 commit 47bf59d

File tree

12 files changed

+1061
-153
lines changed

12 files changed

+1061
-153
lines changed

ydb/core/kqp/ut/scheme/kqp_scheme_ut.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2823,7 +2823,7 @@ Y_UNIT_TEST_SUITE(KqpScheme) {
28232823
auto result = userSession.AlterTable("/Root/SecondaryKeys/Index/indexImplTable", tableSettings).ExtractValueSync();
28242824
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::UNAUTHORIZED, result.GetIssues().ToString());
28252825
UNIT_ASSERT_STRING_CONTAINS(result.GetIssues().ToString(),
2826-
"Error: Access denied for user@builtin to path Root/SecondaryKeys/Index/indexImplTable"
2826+
"Error: Access denied for user@builtin on path Root/SecondaryKeys/Index/indexImplTable"
28272827
);
28282828
}
28292829
// grant necessary permission

ydb/core/kqp/workload_service/actors/scheme_actors.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,19 @@ class TPoolCreatorActor : public TSchemeActorBase<TPoolCreatorActor> {
325325
protected:
326326
void StartRequest() override {
327327
LOG_D("Start pool creating");
328+
const auto& database = DatabaseIdToDatabase(DatabaseId);
329+
328330
auto event = std::make_unique<TEvTxUserProxy::TEvProposeTransaction>();
329331

330332
auto& schemeTx = *event->Record.MutableTransaction()->MutableModifyScheme();
331-
schemeTx.SetWorkingDir(JoinPath({DatabaseIdToDatabase(DatabaseId), ".metadata/workload_manager/pools"}));
333+
schemeTx.SetWorkingDir(JoinPath({database, ".metadata/workload_manager/pools"}));
332334
schemeTx.SetOperationType(NKikimrSchemeOp::ESchemeOpCreateResourcePool);
333335
schemeTx.SetInternal(true);
334336

335337
BuildCreatePoolRequest(*schemeTx.MutableCreateResourcePool());
336338
BuildModifyAclRequest(*schemeTx.MutableModifyACL());
337339

340+
event->Record.SetDatabaseName(database);
338341
if (UserToken) {
339342
event->Record.SetUserToken(UserToken->SerializeAsString());
340343
}

ydb/core/protos/feature_flags.proto

+3
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,7 @@ message TFeatureFlags {
190190
optional bool EnableColumnStore = 165 [default = false];
191191
optional bool EnableStrictAclCheck = 166 [default = false];
192192
optional bool DatabaseYamlConfigAllowed = 167 [default = false];
193+
// deny non-administrators the privilege of administering local users and groups
194+
optional bool EnableStrictUserManagement = 168 [default = false];
195+
optional bool EnableDatabaseAdmin = 169 [default = false];
193196
}

ydb/core/testlib/basics/feature_flags.h

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class TTestFeatureFlagsHolder {
7373
FEATURE_FLAG_SETTER(EnableFollowerStats)
7474
FEATURE_FLAG_SETTER(EnableExportChecksums)
7575
FEATURE_FLAG_SETTER(EnableTopicTransfer)
76+
FEATURE_FLAG_SETTER(EnableStrictUserManagement)
77+
FEATURE_FLAG_SETTER(EnableDatabaseAdmin)
7678

7779
#undef FEATURE_FLAG_SETTER
7880
};

ydb/core/testlib/test_client.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2679,6 +2679,9 @@ namespace Tests {
26792679
TAutoPtr<NMsgBusProxy::TBusBlobStorageConfigRequest> request(new NMsgBusProxy::TBusBlobStorageConfigRequest());
26802680
request->Record.MutableRequest()->AddCommand()->MutableDefineStoragePool()->CopyFrom(storagePool);
26812681
request->Record.SetDomain(Domain);
2682+
if (SecurityToken) {
2683+
request->Record.SetSecurityToken(SecurityToken);
2684+
}
26822685

26832686
TAutoPtr<NBus::TBusMessage> reply;
26842687
NBus::EMessageStatus msgStatus = SendWhenReady(request, reply);

ydb/core/testlib/test_client.h

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ namespace Tests {
300300
FeatureFlags.SetEnableColumnStore(true);
301301
}
302302

303+
TServerSettings() = default;
303304
TServerSettings(const TServerSettings& settings) = default;
304305
TServerSettings& operator=(const TServerSettings& settings) = default;
305306
private:

ydb/core/tx/schemeshard/ut_helpers/test_env.h

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ namespace NSchemeShardUT_Private {
7373
OPTION(std::optional<bool>, EnableTopicTransfer, std::nullopt);
7474
OPTION(bool, SetupKqpProxy, false);
7575
OPTION(bool, EnableStrictAclCheck, false);
76+
OPTION(std::optional<bool>, EnableStrictUserManagement, std::nullopt);
77+
OPTION(std::optional<bool>, EnableDatabaseAdmin, std::nullopt);
7678

7779
#undef OPTION
7880
};

ydb/core/tx/tx_proxy/schemereq.cpp

+294-150
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)