This commit is contained in:
niko4299
2022-07-21 12:33:50 +02:00
parent 5f8ae644ff
commit 019f226b5e
5 changed files with 13 additions and 2 deletions

View File

@@ -20,5 +20,7 @@ class AccessChecker {
public:
virtual bool IsUserAuthorizedEdgeTypes(const std::vector<memgraph::storage::EdgeTypeId> &edgeTypes,
memgraph::query::DbAccessor *dba) const = 0;
virtual std::vector<memgraph::storage::EdgeTypeId> GetGrantedEdgeTypesId(memgraph::query::DbAccessor *dba) const = 0;
};
} // namespace memgraph::query

View File

@@ -273,6 +273,14 @@ class AccessChecker final : public memgraph::query::AccessChecker {
});
}
std::vector<memgraph::storage::EdgeTypeId> GetGrantedEdgeTypesId(memgraph::query::DbAccessor *dba) const final {
auto edgeTypePermissions = user_->GetEdgeTypePermissions().GetGrants();
std::vector<memgraph::storage::EdgeTypeId> edgeTypeIds{};
for (auto edgeTypePermission : edgeTypePermissions) edgeTypeIds.push_back(dba->NameToEdgeType(edgeTypePermission));
return edgeTypeIds;
}
private:
memgraph::auth::User *user_;
};

View File

@@ -732,6 +732,7 @@ bool Expand::ExpandCursor::InitEdges(Frame &frame, ExecutionContext &context) {
auto &vertex = vertex_value.ValueVertex();
auto direction = self_.common_.direction;
if (direction == EdgeAtom::Direction::IN || direction == EdgeAtom::Direction::BOTH) {
if (self_.common_.existing_node) {
TypedValue &existing_node = frame[self_.common_.node_symbol];

View File

@@ -339,7 +339,7 @@ Result<std::map<PropertyId, PropertyValue>> VertexAccessor::Properties(View view
return std::move(properties);
}
Result<std::vector<EdgeAccessor>> VertexAccessor::InEdges(View view, const std::vector<EdgeTypeId> &edge_types,
Result<std::vector<EdgeAccessor>> VertexAccessor::InEdges(View view, AccessChecker *access_checker,
const VertexAccessor *destination) const {
MG_ASSERT(!destination || destination->transaction_ == transaction_, "Invalid accessor!");
bool exists = true;

View File

@@ -81,7 +81,7 @@ class VertexAccessor final {
/// @throw std::bad_alloc
/// @throw std::length_error if the resulting vector exceeds
/// std::vector::max_size().
Result<std::vector<EdgeAccessor>> InEdges(View view, const std::vector<EdgeTypeId> &edge_types = {},
Result<std::vector<EdgeAccessor>> InEdges(View view, AccessChecker *access_checker = nullptr,
const VertexAccessor *destination = nullptr) const;
/// @throw std::bad_alloc