-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
porting protocol changes btween 54455 and 54459 (#504)
- Loading branch information
1 parent
1bc83df
commit d7fe1d5
Showing
62 changed files
with
708 additions
and
263 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include <Access/CachedAccessChecking.h> | ||
#include <Access/ContextAccess.h> | ||
|
||
|
||
namespace DB | ||
{ | ||
CachedAccessChecking::CachedAccessChecking(const std::shared_ptr<const ContextAccess> & access_, AccessFlags access_flags_) | ||
: CachedAccessChecking(access_, AccessRightsElement{access_flags_}) | ||
{ | ||
} | ||
|
||
CachedAccessChecking::CachedAccessChecking(const std::shared_ptr<const ContextAccess> & access_, const AccessRightsElement & element_) | ||
: access(access_), element(element_) | ||
{ | ||
} | ||
|
||
CachedAccessChecking::~CachedAccessChecking() = default; | ||
|
||
bool CachedAccessChecking::checkAccess(bool throw_if_denied) | ||
{ | ||
if (checked) | ||
return result; | ||
if (throw_if_denied) | ||
{ | ||
try | ||
{ | ||
access->checkAccess(element); | ||
result = true; | ||
} | ||
catch (...) | ||
{ | ||
result = false; | ||
throw; | ||
} | ||
} | ||
else | ||
{ | ||
result = access->isGranted(element); | ||
} | ||
checked = true; | ||
return result; | ||
} | ||
|
||
} |
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,29 @@ | ||
#pragma once | ||
|
||
#include <Access/Common/AccessRightsElement.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 ContextAccess> & access_, AccessFlags access_flags_); | ||
CachedAccessChecking(const std::shared_ptr<const ContextAccess> & access_, const AccessRightsElement & element_); | ||
~CachedAccessChecking(); | ||
|
||
bool checkAccess(bool throw_if_denied = true); | ||
|
||
private: | ||
const std::shared_ptr<const ContextAccess> access; | ||
const AccessRightsElement element; | ||
bool checked = false; | ||
bool result = false; | ||
}; | ||
|
||
} |
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.