Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ydb/core/grpc_services/grpc_request_check_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ inline TVector<TEvTicketParser::TEvAuthorizeTicket::TEntry> GetEntriesForAuthAnd
return {};
}
return {
{permissions, {{"gizmo_id", it->second}}}
{permissions, {{"folder_id", it->second}}}
};
} else {
return {};
Expand Down
7 changes: 0 additions & 7 deletions ydb/core/security/ticket_parser_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,6 @@ class TTicketParserImpl : public TActorBootstrapped<TDerived> {
AddNebiusResourcePath(pathsContainer, databaseId);
}

// Use attribute "gizmo_id" as container id that contains cluster access resource
// IAM can link roles for cluster access resource
// Note: "gizmo_id" and "folder_id" are always sent in separate TEvAuthorizeTicket requests
if (const auto gizmoId = record.GetAttributeValue(permission, "gizmo_id"); gizmoId) {
SetNebiusContainerId(pathsContainer, gizmoId);
}

// Use attribute "folder_id" as container id that contains our database
// IAM can link roles for containers hierarchy
if (const auto folderId = record.GetAttributeValue(permission, "folder_id"); folderId) {
Expand Down
41 changes: 30 additions & 11 deletions ydb/core/security/ticket_parser_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1661,17 +1661,36 @@ Y_UNIT_TEST_SUITE(TTicketParserTest) {
UNIT_ASSERT_C(result->Error.empty(), result->Error);
UNIT_ASSERT_C(result->Token->IsExist("something.read-bbbb4554@as"), result->Token->ShortDebugString());

// Authorization successful for gizmo resource
accessServiceMock.AllowedResourceIds.clear();
accessServiceMock.AllowedResourceIds.emplace("gizmo");
runtime->Send(new IEventHandle(MakeTicketParserID(), sender, new TEvTicketParser::TEvAuthorizeTicket(
userToken,
{{"gizmo_id", "gizmo"}, },
{"monitoring.view"})), 0);
result = runtime->GrabEdgeEvent<TEvTicketParser::TEvAuthorizeTicketResult>(handle);
UNIT_ASSERT_C(result->Error.empty(), result->Error);
UNIT_ASSERT_C(result->Token->IsExist("monitoring.view@as"), result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("monitoring.view-gizmo@as"), result->Token->ShortDebugString());
if constexpr (!IsNebiusAccessService<TAccessServiceMock>()) {
// Authorization successful for gizmo resource
accessServiceMock.AllowedResourceIds.clear();
accessServiceMock.AllowedResourceIds.emplace("gizmo");
runtime->Send(new IEventHandle(MakeTicketParserID(), sender, new TEvTicketParser::TEvAuthorizeTicket(
userToken,
{{"gizmo_id", "gizmo"}, },
{"monitoring.view"})), 0);
result = runtime->GrabEdgeEvent<TEvTicketParser::TEvAuthorizeTicketResult>(handle);
UNIT_ASSERT_C(result->Error.empty(), result->Error);
UNIT_ASSERT_VALUES_EQUAL_C(result->Token->GetGroupSIDs().size(), 4, result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("all-users@well-known"), result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("monitoring.view@as"), result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("monitoring.view-gizmo@as"), result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("user1@as"), result->Token->ShortDebugString());
} else {
// Authorization successful for cluster resource
accessServiceMock.AllowedResourceIds.clear();
accessServiceMock.AllowedResourceIds.emplace("folder");
runtime->Send(new IEventHandle(MakeTicketParserID(), sender, new TEvTicketParser::TEvAuthorizeTicket(
userToken,
{{"folder_id", "folder"}, },
{"monitoring.view"})), 0);
result = runtime->GrabEdgeEvent<TEvTicketParser::TEvAuthorizeTicketResult>(handle);
UNIT_ASSERT_C(result->Error.empty(), result->Error);
UNIT_ASSERT_VALUES_EQUAL_C(result->Token->GetGroupSIDs().size(), 3, result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("all-users@well-known"), result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("monitoring.view@as"), result->Token->ShortDebugString());
UNIT_ASSERT_C(result->Token->IsExist("user1@as"), result->Token->ShortDebugString());
}
}

Y_UNIT_TEST(Authorization) {
Expand Down
Loading