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
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()));
60 bool operator==(
const acl_rule& lhs,
const acl_rule& rhs)
62 return lhs.scheme() == rhs.scheme()
63 && lhs.id() == rhs.id()
64 && lhs.permissions() == rhs.permissions();
67 bool operator!=(
const acl_rule& lhs,
const acl_rule& rhs)
72 bool operator< (
const acl_rule& lhs,
const acl_rule& rhs)
74 return std::tie(lhs.scheme(), lhs.id(), lhs.permissions()) < std::tie(rhs.scheme(), rhs.id(), rhs.permissions());
77 bool operator<=(
const acl_rule& lhs,
const acl_rule& rhs)
82 bool operator> (
const acl_rule& lhs,
const acl_rule& rhs)
87 bool operator>=(
const acl_rule& lhs,
const acl_rule& rhs)
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;
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;
acl()=default
Create an empty ACL. Keep in mind that an empty ACL is an illegal ACL.
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.
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.
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.
std::size_t hash(const acl_rule &self)
Compute a hash for the given rule.