forked from ydb-platform/ydb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SystemView Auth Permissions (ydb-platform#13403)
- Loading branch information
Showing
8 changed files
with
408 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#include "auth_scan_base.h" | ||
#include "permissions.h" | ||
|
||
#include <ydb/core/sys_view/common/events.h> | ||
#include <ydb/core/sys_view/common/schema.h> | ||
#include <ydb/core/sys_view/common/scan_actor_base_impl.h> | ||
#include <ydb/core/base/tablet_pipecache.h> | ||
#include <ydb/core/ydb_convert/ydb_convert.h> | ||
#include <ydb/library/login/protos/login.pb.h> | ||
|
||
#include <ydb/library/actors/core/hfunc.h> | ||
|
||
namespace NKikimr::NSysView::NAuth { | ||
|
||
using namespace NSchemeShard; | ||
using namespace NActors; | ||
|
||
class TPermissionsScan : public TAuthScanBase<TPermissionsScan> { | ||
public: | ||
using TScanBase = TScanActorBase<TPermissionsScan>; | ||
using TAuthBase = TAuthScanBase<TPermissionsScan>; | ||
|
||
TPermissionsScan(bool effective, const NActors::TActorId& ownerId, ui32 scanId, const TTableId& tableId, | ||
const TTableRange& tableRange, const TArrayRef<NMiniKQL::TKqpComputeContextBase::TColumn>& columns) | ||
: TAuthBase(ownerId, scanId, tableId, tableRange, columns) | ||
, Effective(effective) | ||
{ | ||
} | ||
|
||
protected: | ||
void FillBatch(NKqp::TEvKqpCompute::TEvScanData& batch, const TNavigate::TEntry& entry) override { | ||
Y_ABORT_UNLESS(entry.Status == TNavigate::EStatus::Ok); | ||
|
||
TVector<TCell> cells(::Reserve(Columns.size())); | ||
|
||
// TODO: add rows according to request's sender user rights | ||
|
||
auto entryPath = CanonizePath(entry.Path); | ||
|
||
for (const NACLibProto::TACE& ace : entry.SecurityObject->GetACL().GetACE()) { | ||
if (ace.GetAccessType() != (ui32)NACLib::EAccessType::Allow) { | ||
continue; | ||
} | ||
if (!Effective && ace.GetInherited()) { | ||
continue; | ||
} | ||
|
||
auto permissions = ConvertACLMaskToYdbPermissionNames(ace.GetAccessRight()); | ||
for (const auto& permission : permissions) { | ||
for (auto& column : Columns) { | ||
switch (column.Tag) { | ||
case Schema::AuthPermissions::Path::ColumnId: | ||
cells.push_back(TCell(entryPath.data(), entryPath.size())); | ||
break; | ||
case Schema::AuthPermissions::Sid::ColumnId: | ||
if (ace.HasSID()) { | ||
cells.push_back(TCell(ace.GetSID().data(), ace.GetSID().size())); | ||
} else { | ||
cells.emplace_back(); | ||
} | ||
break; | ||
case Schema::AuthPermissions::Permission::ColumnId: | ||
cells.push_back(TCell(permission.data(), permission.size())); | ||
break; | ||
default: | ||
cells.emplace_back(); | ||
} | ||
} | ||
|
||
TArrayRef<const TCell> ref(cells); | ||
batch.Rows.emplace_back(TOwnedCellVec::Make(ref)); | ||
cells.clear(); | ||
} | ||
} | ||
|
||
batch.Finished = false; | ||
} | ||
|
||
private: | ||
const bool Effective; | ||
}; | ||
|
||
THolder<NActors::IActor> CreatePermissionsScan(bool effective, const NActors::TActorId& ownerId, ui32 scanId, const TTableId& tableId, | ||
const TTableRange& tableRange, const TArrayRef<NMiniKQL::TKqpComputeContextBase::TColumn>& columns) | ||
{ | ||
return MakeHolder<TPermissionsScan>(effective, ownerId, scanId, tableId, tableRange, columns); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#pragma once | ||
|
||
#include <ydb/core/kqp/runtime/kqp_compute.h> | ||
|
||
#include <ydb/library/actors/core/actor.h> | ||
#include <ydb/library/actors/core/actorid.h> | ||
|
||
namespace NKikimr::NSysView::NAuth { | ||
|
||
THolder<NActors::IActor> CreatePermissionsScan(bool effective, const NActors::TActorId& ownerId, ui32 scanId, const TTableId& tableId, | ||
const TTableRange& tableRange, const TArrayRef<NMiniKQL::TKqpComputeContextBase::TColumn>& columns); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ SRCS( | |
groups.h | ||
owners.cpp | ||
owners.h | ||
permissions.cpp | ||
permissions.h | ||
users.cpp | ||
users.h | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.