ClickHouse/src/Access/CachedAccessChecking.h
Alex Katsman ca0da7a481 Add query privileges information to the query log.
Introduced two additional columns in the system.query_log:
used_privileges and missing_privileges. Used_privileges is populated
with the privileges that were checked during query execution, and
missing_privileges contains required privileges that are missing.
2024-06-18 15:39:21 +00:00

31 lines
827 B
C++

#pragma once
#include <Access/Common/AccessRightsElement.h>
#include <Access/ContextAccess.h>
#include <memory>
namespace DB
{
class ContextAccess;
/// Checks if the current user has a specified access type granted,
/// and if it's checked another time later, it will just return the first result.
class CachedAccessChecking
{
public:
CachedAccessChecking(const std::shared_ptr<const ContextAccessWrapper> & access_, AccessFlags access_flags_);
CachedAccessChecking(const std::shared_ptr<const ContextAccessWrapper> & access_, const AccessRightsElement & element_);
~CachedAccessChecking();
bool checkAccess(bool throw_if_denied = true);
private:
const std::shared_ptr<const ContextAccessWrapper> access;
const AccessRightsElement element;
bool checked = false;
bool result = false;
};
}