Web framework C++
2.0.0
Simple web framework on c++ designed to easily create web pages, etc
|
Proxy handler template to control access to another handlers. More...
#include <authorized_handler.h>
Public Member Functions | |
AuthorizedHandler (Handler *realHandler, const char *middlewareID, std::function< bool(Entity *)> checkAccess=nullptr) | |
~AuthorizedHandler () override | |
void | exec () override |
void | setAccessCheck (std::function< bool(Entity *)> checkAccess) |
void | setNext (Handler *next) override |
void | add (Handler *handler) override |
![]() | |
Handler (const char *route=nullptr, HTTP::Method method=HTTP::Method::ANY, Handler *next=nullptr) | |
virtual | ~Handler () |
bool | isRouted () |
std::string | getRoute () |
HTTP::Method | getMethod () |
void | setContext (Context *context) |
void | handleRequest () |
Additional Inherited Members | |
![]() | |
Context * | getContext () |
Proxy handler template to control access to another handlers.
Any handlers or chain of handlers could be wrapped by this handler. All that you need is to create an example of this class and pass a concrete handler, which should be controlled, and function, which checks if current user could access such resource. Could substitute passed handlers with 403 or 401 error pages
AuthorizedHandler::AuthorizedHandler | ( | Handler * | realHandler, |
const char * | middlewareID, | ||
std::function< bool(Entity *)> | checkAccess = nullptr |
||
) |
Create proxy handler, which wraps passed one
realHandler | handler and other handlers connected after it, which should be wrapped |
middlewareID | ID of AuthMiddleware, added to application |
checkAccess | function, that checks, if current user could see such resource. If not, user should see 403 forbidden error page, if there are no user authenticated - 401 unauthenticated error page |
|
override |
destructs inner oblects
|
overridevirtual |
Add handler to tail of wrapped handler chain of responsibility
handler | handler object |
Reimplemented from Handler.
|
overridevirtual |
Execute real handler, if user has access
Implements Handler.
void AuthorizedHandler::setAccessCheck | ( | std::function< bool(Entity *)> | checkAccess | ) |
Set function, that checks if user could access resource
checkAccess | function that return true if user has access |
|
overridevirtual |