diff --git a/README.md b/README.md index 4c43b145..670337c9 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ working correctly. Some common problems are: itself to protect a potentially non-development environment. 3. If you are using the [Authorization Plugin](https://github.com/cakephp/authorization) you need to set `DebugKit.ignoreAuthorization` to `true` in your config. + Not needed anymore for DebugKit 5.3.0+. ## Reporting Issues diff --git a/docs/en/index.rst b/docs/en/index.rst index ea09efdc..bc639244 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -62,7 +62,8 @@ Configuration // Ignore image paths Configure::write('DebugKit.ignorePathsPattern', '/\.(jpg|png|gif)$/'); -* ``DebugKit.ignoreAuthorization`` - Set to true to ignore Cake Authorization plugin for DebugKit requests. Disabled by default. +* ``DebugKit.ignoreAuthorization`` - Set to true to ignore Cake Authorization plugin for DebugKit requests. + Not needed anymore for DebugKit 5.3.0+. * ``DebugKit.maxDepth`` - Defines how many levels of nested data should be shown in general for debug output. Default is 5. WARNING: Increasing the max depth level can lead to an out of memory error.:: diff --git a/src/Controller/DebugKitController.php b/src/Controller/DebugKitController.php index d9d3a05b..486ca818 100644 --- a/src/Controller/DebugKitController.php +++ b/src/Controller/DebugKitController.php @@ -43,7 +43,7 @@ public function beforeFilter(EventInterface $event): void // ignore it, only if `DebugKit.ignoreAuthorization` is set to true $authorizationService = $this->getRequest()->getAttribute('authorization'); if ($authorizationService instanceof AuthorizationService) { - if (Configure::read('DebugKit.ignoreAuthorization')) { + if (Configure::read('DebugKit.ignoreAuthorization') !== false) { $authorizationService->skipAuthorization(); } else { Log::info( diff --git a/tests/TestCase/Controller/DebugKitControllerTest.php b/tests/TestCase/Controller/DebugKitControllerTest.php index 75f51cca..9987e8c3 100644 --- a/tests/TestCase/Controller/DebugKitControllerTest.php +++ b/tests/TestCase/Controller/DebugKitControllerTest.php @@ -67,33 +67,33 @@ private function _buildController() } /** - * tests authorization is enabled but not ignored + * tests authorization is checked to avoid + * AuthorizationRequiredException throwned * * @return void */ - public function testDontIgnoreAuthorization() + public function testIgnoreAuthorization() { $controller = $this->_buildController(); $event = new Event('testing'); $controller->beforeFilter($event); - $this->assertFalse($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); + $this->assertTrue($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); } /** - * tests authorization is checked to avoid - * AuthorizationRequiredException throwned + * tests authorization is enabled but not ignored * * @return void */ - public function testIgnoreAuthorization() + public function testDontIgnoreAuthorization() { - Configure::write('DebugKit.ignoreAuthorization', true); + Configure::write('DebugKit.ignoreAuthorization', false); $controller = $this->_buildController(); $event = new Event('testing'); $controller->beforeFilter($event); - $this->assertTrue($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); + $this->assertFalse($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); } }