25 #include <boost/algorithm/string/predicate.hpp> 34 if (boost::algorithm::ends_with(req,
".read"))
36 else if (boost::algorithm::ends_with(req,
".create"))
38 else if (boost::algorithm::ends_with(req,
".update"))
40 else if (boost::algorithm::ends_with(req,
".delete"))
45 <<
"} for CRUD resource handler");
51 const std::vector<ActionActionParam> &permissions)
54 for (
const auto &action_and_param : permissions)
56 if (!security_ctx.check_permission(action_and_param.first,
57 action_and_param.second))
100 ASSERT_LOG(wsc,
"SecurityContext has unexpected type.");
virtual std::vector< ActionActionParam > required_permission(Verb verb, const json &req) const =0
This is the header file for a generated source file, GitSHA1.cpp.
virtual boost::optional< json > update_impl(const json &req)=0
ModuleRequestContext ctx_
CRUDResourceHandler(RequestContext ctx)
virtual boost::optional< json > create_impl(const json &req)=0
A request context dedicated for websocket request that are handled by other modules.
virtual UserSecurityContext & security_context() const override
Helper function that returns the security context.
std::unique_ptr< CRUDResourceHandler > CRUDResourceHandlerUPtr
static Verb verb_from_request_type(const std::string &)
An exception that can be throw when the permission for a given operation is denied.
boost::optional< json > process(const ClientMessage &msg)
All modules that provides features to Leosac shall be in this namespace.
#define ASSERT_LOG(cond, msg)
ExternalCRUDResourceHandler(ModuleRequestContext ctx)
virtual UserSecurityContext & security_context() const override
Helper function that returns the security context.
A base class for Leosac specific exception.
static CRUDResourceHandlerUPtr instanciate(RequestContext)
A message sent by a client to Leosac.
UserSecurityContext * security_ctx
The object lifetime will not expand past the current request processing.
virtual UserSecurityContext & security_context() const =0
Helper function that returns the security context.
virtual boost::optional< json > delete_impl(const json &req)=0
Holds valuable pointer to provide context to a request.
A SecurityContext object for users.
virtual boost::optional< json > read_impl(const json &req)=0
void enforce_permission(const std::vector< ActionActionParam > &)