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$_SESSION
global variable;RBAC
: Role Based Access Control that can check if a role has access granted to a "ressource" (Controller
method).
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
User
isn't authed and that theRequest
requires a authedUser
to be executed, the client should be redirected to a login page; - If the
RBAC
sees that the authedUser
doesn'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 theUser
did not have the permission to do so (Example: AUser
writes an article but doesn't have the right to publish it, so the article is saved as a draft and theUser
is told that aModerator
will have to publish it).
I already have a few ideas where to locate the Authentification
and RBAC
but I'm not sure:
Authentification
could go in theFrontController
or theRouter
;RBAC
could go in theFrontController
or 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!