1 | <?php |
||
43 | class Auth |
||
44 | { |
||
45 | use AuthenticateTrait; |
||
46 | use AuthorizeTrait; |
||
47 | use EventDispatcherTrait; |
||
48 | use InstanceConfigTrait; |
||
49 | use LogTrait; |
||
50 | use StorageTrait; |
||
51 | |||
52 | /** |
||
53 | * Actions for which user validation is not required. |
||
54 | * |
||
55 | * @var array |
||
56 | */ |
||
57 | public $allowedActions = []; |
||
58 | |||
59 | /** |
||
60 | * Request object |
||
61 | * |
||
62 | * @var \Cake\Http\ServerRequest |
||
63 | */ |
||
64 | public $request; |
||
65 | |||
66 | /** |
||
67 | * Response object |
||
68 | * |
||
69 | * @var \Cake\Http\Response |
||
70 | */ |
||
71 | public $response; |
||
72 | |||
73 | /** |
||
74 | * Default config |
||
75 | * |
||
76 | * These are merged with user-provided config when the component is used. |
||
77 | * |
||
78 | * @var array |
||
79 | */ |
||
80 | protected $_defaultConfig = [ |
||
81 | 'storage' => 'Memory', |
||
82 | ]; |
||
83 | |||
84 | protected $_registry = null; |
||
85 | |||
86 | /** |
||
87 | * @var Service |
||
88 | */ |
||
89 | protected $_service; |
||
90 | |||
91 | /** |
||
92 | * @var Action |
||
93 | */ |
||
94 | protected $_action; |
||
95 | |||
96 | /** |
||
97 | * Constructor |
||
98 | * |
||
99 | * @param array $config Array of configuration settings. |
||
100 | */ |
||
101 | 123 | public function __construct(array $config = []) |
|
112 | |||
113 | /** |
||
114 | * Initialize properties. |
||
115 | * |
||
116 | * @param array $config The config data. |
||
117 | * @return void |
||
118 | */ |
||
119 | 123 | public function initialize(array $config) |
|
129 | |||
130 | /** |
||
131 | * Sets defaults for configs. |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | 60 | protected function _setDefaults() |
|
150 | |||
151 | /** |
||
152 | * Takes a list of actions in the current controller for which authentication is not required, or |
||
153 | * no parameters to allow all actions. |
||
154 | * |
||
155 | * You can use allow with either an array or a simple string. |
||
156 | * |
||
157 | * ``` |
||
158 | * $this->Auth->allow('view'); |
||
159 | * $this->Auth->allow(['edit', 'add']); |
||
160 | * |
||
161 | * @param string|array $actions Controller action name or array of actions |
||
162 | * @return void |
||
163 | */ |
||
164 | 14 | public function allow($actions) |
|
168 | |||
169 | /** |
||
170 | * Removes items from the list of allowed/no authentication required actions. |
||
171 | * |
||
172 | * You can use deny with either an array or a simple string. |
||
173 | * |
||
174 | * ``` |
||
175 | * $this->Auth->deny('view'); |
||
176 | * $this->Auth->deny(['edit', 'add']); |
||
177 | * ``` |
||
178 | * or |
||
179 | * ``` |
||
180 | * $this->Auth->deny(); |
||
181 | * ``` |
||
182 | * to remove all items from the allowed list |
||
183 | * |
||
184 | * @param string|array|null $actions Controller action name or array of actions |
||
185 | * @return void |
||
186 | */ |
||
187 | public function deny($actions = null) |
||
202 | |||
203 | /** |
||
204 | * Main execution method, handles initial authentication check and redirection |
||
205 | * of invalid users. |
||
206 | * |
||
207 | * The auth check is done when event name is same as the one configured in |
||
208 | * `checkAuthIn` config. |
||
209 | * |
||
210 | * @param \Cake\Event\Event $event Event instance. |
||
211 | * @return Response|null |
||
212 | */ |
||
213 | 60 | public function authCheck(Event $event) |
|
235 | |||
236 | /** |
||
237 | * Checks whether current action is accessible without authentication. |
||
238 | * |
||
239 | * @param Action $action An Action instance. |
||
240 | * @return bool True if action is accessible without authentication else false |
||
241 | */ |
||
242 | 60 | protected function _isAllowed(Action $action) |
|
249 | |||
250 | /** |
||
251 | * __get method this method will return an attribute of this class |
||
252 | * |
||
253 | * @param string $name Name |
||
254 | * @return mixed |
||
255 | */ |
||
256 | public function __get($name) |
||
264 | |||
265 | /** |
||
266 | * __set method this method will allow you set the value for an attribute of this class |
||
267 | * |
||
268 | * @param string $name name of the attribute |
||
269 | * @param string $value value of the attribute |
||
270 | * @return void |
||
271 | */ |
||
272 | public function __set($name, $value) |
||
276 | } |
||
277 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.