|
Leosac
0.8.0
Open Source Access Control
|
Go to the documentation of this file.
25 #include "core/auth/Door_odb.h"
54 odb::transaction t(db->begin());
60 db->persist(new_door);
67 audit->access_point_id_after(new_door->access_point_id());
79 using Result = odb::result<Auth::Door>;
81 odb::transaction t(db->begin());
92 rep[
"data"] = json::array();
96 for (
const auto &door : result)
99 if (
ctx_.
session->security_context().check_permission(
102 rep[
"data"].push_back(
115 odb::transaction t(db->begin());
119 auto door_odb = assert_cast<Auth::DoorPtr>(door);
124 audit->access_point_id_before(door->access_point_id());
129 db->update(door_odb);
132 audit->access_point_id_after(door->access_point_id());
144 odb::transaction t(db->begin());
147 auto door_odb = assert_cast<Auth::DoorPtr>(door);
151 audit->access_point_id_before(door->access_point_id());
162 std::vector<CRUDResourceHandler::ActionActionParam>
165 std::vector<CRUDResourceHandler::ActionActionParam> ret;
171 catch (json::out_of_range &e)
200 odb::query<Auth::Door>::access_point == apid);
206 "The AccessPoint with id {} is already referenced by door with id {}.",
An optional transaction is an object that behave like an odb::transaction if there is no currently ac...
void commit()
Commit the transaction, if there was no currently active transaction at the time of this object's cre...
static SecurityContext & instance()
DoorCRUD(RequestContext ctx)
virtual boost::optional< json > delete_impl(const json &req) override
static json serialize(const Auth::IDoor &door, const SecurityContext &sc)
virtual boost::optional< json > create_impl(const json &req) override
std::unique_ptr< CRUDResourceHandler > CRUDResourceHandlerUPtr
Base CRUD handler for use within the websocket module.
static IDoorEventPtr DoorEvent(const DBPtr &database, Auth::IDoorPtr target_door, IAuditEntryPtr parent)
std::shared_ptr< odb::database > DBPtr
static void unserialize(Auth::IDoor &out, const json &in, const SecurityContext &sc)
All modules that provides features to Leosac shall be in this namespace.
static CRUDResourceHandlerUPtr instanciate(RequestContext)
This is the header file for a generated source file, GitSHA1.cpp.
virtual std::vector< ActionActionParam > required_permission(Verb verb, const json &req) const override
std::shared_ptr< Door > DoorPtr
A base class for Leosac specific exception.
static std::string serialize(const Auth::IDoor &in, const SecurityContext &sc)
virtual boost::optional< json > read_impl(const json &req) override
Audit::IAuditEntryPtr audit
The initial audit trail for the request.
std::string format(const std::string &escape_code, const T &in)
Return a string containing the escape code, a string representation of T and the clear escape string.
Holds valuable pointer to provide context to a request.
void enforce_ap_not_already_referenced(Auth::AccessPointId apid)
Make sure that the AccessPoint with id apid is not already referenced by a door.
#define LEOSAC_ENFORCE(cond,...)
Similar to enforce, except that it will throw a LEOSACException.
odb::result< Tools::LogEntry > Result
virtual boost::optional< json > update_impl(const json &req) override
unsigned long AccessPointId
virtual UserSecurityContext & security_context() const override
Helper function that returns the security context.