jdmaymeow / cake-auth
CakeAuth plugin for CakePHP
Installs: 76
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.5.9
- cakephp/cakephp: >=3.3.2 <4.0.0
- jdmaymeow/cake-bootstrap: 1.2.*
- jdmaymeow/cake-file: ~1.1
Requires (Dev)
README
This is part of Code Advent 2016
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require jdmaymeow/cake-auth
Load plugin
bin/cake plugin load CakeAuth -r
Configure
To AppController Initialize add
$this->loadComponent('Auth', [ 'authorize' => ['Controller'], // Added this line 'loginRedirect' => [ 'controller' => 'Links', 'action' => 'index' ], 'logoutRedirect' => [ 'controller' => 'Users', 'action' => 'login', 'home' ] ]);
Add after initialize function into main APpControler
public function beforeFilter(Event $event) { $this->Auth->allow(['index', 'view', 'display']); } public function isAuthorized($user) { // Admin can access every action if (isset($user['role']) && $user['role'] === 'admin') { return true; } // Default deny return false; }
Standard Configuration
Allowed actions
Role | Login | Logout | Index | Add | Edit | View | Delete | Display |
---|---|---|---|---|---|---|---|---|
Author | Yes | Yes | Yes | Yes | No | Yes | No | Yes |
Admin | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes |