BaseAuthorize.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 2.0.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Auth;
  16. use Cake\Controller\ComponentRegistry;
  17. use Cake\Core\InstanceConfigTrait;
  18. use Cake\Network\Request;
  19. /**
  20. * Abstract base authorization adapter for AuthComponent.
  21. *
  22. * @see AuthComponent::$authenticate
  23. */
  24. abstract class BaseAuthorize
  25. {
  26. use InstanceConfigTrait;
  27. /**
  28. * ComponentRegistry instance for getting more components.
  29. *
  30. * @var ComponentRegistry
  31. */
  32. protected $_registry;
  33. /**
  34. * Default config for authorize objects.
  35. *
  36. * @var array
  37. */
  38. protected $_defaultConfig = [];
  39. /**
  40. * Constructor
  41. *
  42. * @param ComponentRegistry $registry The controller for this request.
  43. * @param array $config An array of config. This class does not use any config.
  44. */
  45. public function __construct(ComponentRegistry $registry, array $config = [])
  46. {
  47. $this->_registry = $registry;
  48. $this->config($config);
  49. }
  50. /**
  51. * Checks user authorization.
  52. *
  53. * @param array $user Active user data
  54. * @param \Cake\Network\Request $request Request instance.
  55. * @return bool
  56. */
  57. abstract public function authorize($user, Request $request);
  58. }