15 std::ostream& operator<<(std::ostream& os,
const permission&
self)
23 auto tick = [&] {
return std::exchange(first,
false) ?
"" :
"|"; };
35 std::ostringstream os;
45 _scheme(
std::move(scheme)),
47 _permissions(permissions)
50 acl_rule::~acl_rule() noexcept
53 std::size_t hash(
const acl_rule&
self)
55 return std::hash<std::string>{}(
self.scheme())
56 ^ std::hash<std::string>{}(
self.id())
57 ^ std::hash<unsigned int>{}(
static_cast<unsigned int>(
self.permissions()));
63 && lhs.
id() == rhs.
id()
92 std::ostream& operator<<(std::ostream& os,
const acl_rule&
self)
94 os <<
'(' <<
self.scheme();
95 if (!
self.
id().empty())
96 os <<
':' <<
self.id();
97 os <<
", " <<
self.permissions() <<
')';
101 std::string to_string(
const acl_rule&
self)
103 std::ostringstream os;
112 acl::acl(std::vector<acl_rule> rules) noexcept :
113 _impl(std::move(rules))
119 bool operator==(
const acl& lhs,
const acl& rhs)
121 return std::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend());
124 bool operator!=(
const acl& lhs,
const acl& rhs)
126 return !(lhs == rhs);
129 std::ostream& operator<<(std::ostream& os,
const acl&
self)
133 for (
const auto& x :
self)
144 std::string to_string(
const acl&
self)
146 std::ostringstream os;
static const acl & read_unsafe()
This ACL gives the world the ability to read.
You can alter permissions on this node.
An individual rule in an acl.
const permission & permissions() const
The permissions associated with this ACL.
constexpr bool allows(permission self, permission perform)
Check that self allows it perform all operations.
static const acl & creator_all()
This ACL gives the creators authentication id's all permissions.
No permissions are set (server could have been configured without ACL support).
static const acl & open_unsafe()
This is a completely open ACL.
You can create a child node.
You can access the data of a node and can list its children.
const std::string & id() const
The ID of the user under the scheme.
const std::string & scheme() const
The authentication scheme this list is used for.
permission
Describes the ability of a user to perform a certain action.
An access control list is a wrapper around acl_rule instances.
You can erase a child node (but not necessarily this one).
You can set the data of a node.
acl_rule(std::string scheme, std::string id, permission permissions)
Create an ACL under the given scheme and id with the given permissions.