Zend application with multiple inputs

I want to have several logins in one zend application.

I have five sections A, B, C, D, E and four types of users (P, Q, R, S), including an anonymous user. There are subsections in this section. Section A, B, C requires a login to access them. Sections D and E are accessed by all types of users, but there are some actions that certain types of users can follow.

P can connect only to seconds A, Q can connect to sec. B and R can connect to seconds C.

Can you suggest what directory structure should I use, and how can I implement several logins.

thanks

+4
source share
3 answers

the directory structure has nothing to do with access rights. all your application can be one controller and be capable of your concept of roles and rights, but there will be no pleasant tbh code.

If you do not want to use Zend_Acl (why not?), You could solve this problem by running the following concept:

create an application module for each of your "sections", including the PublicController in each application, access to which will be available later. then you should implement a front controller plugin that might look like this

public function preDispatch() { $identity = Zend_Auth::getInstance()->getIdentity(); $module = $this->getRequest()->getModuleName(); $controller = $this->getRequest()->getControllerName(); if($controller == 'public') { return; } switch ($identity->role) { case 'A': if ($module != 'P') { $this->myNotAuthorized(); } break; // cases for other roles/modules } } 
+2
source

You are probably looking for a role-based access control list .
The Zend Framework offers this through Zend_Acl .

See also:

+1
source

You can also do this in a simple way so as not to implement Zend_ACL if you do not want it.

Use session variables and check for access to the module.

0
source

Source: https://habr.com/ru/post/1313373/


All Articles