I'm working on an MVC application with this structure:
Request
V
FrontController <-> Router
V
Controller <-> Model
V
View
I have two other components that I need to place in this structure:
Authentification: Logs the user in using the$_SESSIONglobal variable;RBAC: Role Based Access Control that can check if a role has access granted to a "ressource" (Controllermethod).
Every users can have any given number of roles (they can also have none).
Now, I need to place those two components in my applications, I need them to be able to:
- If the
Userisn't authed and that theRequestrequires a authedUserto be executed, the client should be redirected to a login page; - If the
RBACsees that the authedUserdoesn't have a role that has access granted to the required "ressource" to execute theController's method, theController's method should still be executed but with knowledge that theUserdid not have the permission to do so (Example: AUserwrites an article but doesn't have the right to publish it, so the article is saved as a draft and theUseris told that aModeratorwill have to publish it).
I already have a few ideas where to locate the Authentification and RBAC but I'm not sure:
Authentificationcould go in theFrontControlleror theRouter;RBACcould go in theFrontControlleror theController.
I saw someone putting the RBAC in the model but I don't understand why.
I'd like to have some insight on the subject please. Where should I put the Authentification and RBAC components?
Thank you!