diff --git a/ydb/core/grpc_services/grpc_request_check_actor.h b/ydb/core/grpc_services/grpc_request_check_actor.h index 3a3e86de3db7..30efaeff4641 100644 --- a/ydb/core/grpc_services/grpc_request_check_actor.h +++ b/ydb/core/grpc_services/grpc_request_check_actor.h @@ -38,11 +38,12 @@ bool TGRpcRequestProxyHandleMethods::ValidateAndReplyOnError(TCtx* ctx) { } } -inline TVector GetEntriesForAuthAndCheckRequest(TEvRequestAuthAndCheck::TPtr& ev, const TVector>& rootAttributes) { +inline TVector GetEntriesForAuthAndCheckRequest(TEvRequestAuthAndCheck::TPtr& ev) { const bool isBearerToken = ev->Get()->YdbToken && ev->Get()->YdbToken->StartsWith("Bearer"); const bool useAccessService = AppData()->AuthConfig.GetUseAccessService(); const bool needClusterAccessResourceCheck = AppData()->DomainsConfig.GetSecurityConfig().ViewerAllowedSIDsSize() > 0 || - AppData()->DomainsConfig.GetSecurityConfig().MonitoringAllowedSIDsSize() > 0; + AppData()->DomainsConfig.GetSecurityConfig().MonitoringAllowedSIDsSize() > 0 || + AppData()->DomainsConfig.GetSecurityConfig().AdministrationAllowedSIDsSize() > 0; if (!isBearerToken || !useAccessService || !needClusterAccessResourceCheck) { return {}; @@ -55,7 +56,23 @@ inline TVector GetEntriesForAuthAnd {NKikimr::TEvTicketParser::TEvAuthorizeTicket::ToPermissions({"ydb.developerApi.get", "ydb.developerApi.update"}), {{"gizmo_id", "gizmo"}}} }; return entries; - } else if (accessServiceType == "Nebius_v1") { + } else { + return {}; + } +} + +inline TVector GetEntriesForClusterAccessCheck(const TVector>& rootAttributes) { + const bool useAccessService = AppData()->AuthConfig.GetUseAccessService(); + const bool needClusterAccessResourceCheck = AppData()->DomainsConfig.GetSecurityConfig().ViewerAllowedSIDsSize() > 0 || + AppData()->DomainsConfig.GetSecurityConfig().MonitoringAllowedSIDsSize() > 0 || + AppData()->DomainsConfig.GetSecurityConfig().AdministrationAllowedSIDsSize() > 0; + + if (!useAccessService || !needClusterAccessResourceCheck) { + return {}; + } + + const TString& accessServiceType = AppData()->AuthConfig.GetAccessServiceType(); + if (accessServiceType == "Nebius_v1") { static const auto permissions = NKikimr::TEvTicketParser::TEvAuthorizeTicket::ToPermissions({ "ydb.clusters.get", "ydb.clusters.monitor", "ydb.clusters.manage" }); @@ -123,10 +140,13 @@ class TGrpcRequestCheckActor } if constexpr (std::is_same_v) { - const auto& e = GetEntriesForAuthAndCheckRequest(Request_, rootAttributes); - entries.insert(entries.end(), e.begin(), e.end()); + TVector authCheckRequestEntries = GetEntriesForAuthAndCheckRequest(Request_); + entries.insert(entries.end(), authCheckRequestEntries.begin(), authCheckRequestEntries.end()); } + TVector clusterAccessCheckEntries = GetEntriesForClusterAccessCheck(rootAttributes); + entries.insert(entries.end(), clusterAccessCheckEntries.begin(), clusterAccessCheckEntries.end()); + if (!entries.empty()) { SetEntries(entries); }