-
Notifications
You must be signed in to change notification settings - Fork 694
SystemView Auth Permissions #13403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
SystemView Auth Permissions #13403
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.