1: <?php
2: /**
3: * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
4: * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
5: *
6: * Licensed under The MIT License
7: * For full copyright and license information, please see the LICENSE.txt
8: * Redistributions of files must retain the above copyright notice.
9: *
10: * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
11: * @link https://cakephp.org CakePHP(tm) Project
12: * @since 2.0.0
13: * @license https://opensource.org/licenses/mit-license.php MIT License
14: */
15: namespace Cake\Auth;
16:
17: use Cake\Controller\ComponentRegistry;
18: use Cake\Core\InstanceConfigTrait;
19: use Cake\Http\ServerRequest;
20:
21: /**
22: * Abstract base authorization adapter for AuthComponent.
23: *
24: * @see \Cake\Controller\Component\AuthComponent::$authenticate
25: */
26: abstract class BaseAuthorize
27: {
28: use InstanceConfigTrait;
29:
30: /**
31: * ComponentRegistry instance for getting more components.
32: *
33: * @var \Cake\Controller\ComponentRegistry
34: */
35: protected $_registry;
36:
37: /**
38: * Default config for authorize objects.
39: *
40: * @var array
41: */
42: protected $_defaultConfig = [];
43:
44: /**
45: * Constructor
46: *
47: * @param \Cake\Controller\ComponentRegistry $registry The controller for this request.
48: * @param array $config An array of config. This class does not use any config.
49: */
50: public function __construct(ComponentRegistry $registry, array $config = [])
51: {
52: $this->_registry = $registry;
53: $this->setConfig($config);
54: }
55:
56: /**
57: * Checks user authorization.
58: *
59: * @param array|\ArrayAccess $user Active user data
60: * @param \Cake\Http\ServerRequest $request Request instance.
61: * @return bool
62: */
63: abstract public function authorize($user, ServerRequest $request);
64: }
65: