From 8c81e89e3e000b422f7dc2addaabb5023d442b79 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 14 Nov 2025 03:08:41 +0100 Subject: [PATCH 1/3] Allow debug mode by default. --- README.md | 1 + docs/en/index.rst | 3 ++- src/Controller/DebugKitController.php | 2 +- .../TestCase/Controller/DebugKitControllerTest.php | 14 -------------- 4 files changed, 4 insertions(+), 16 deletions(-) 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..e4d7db7c 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') || Configure::read('debug')) { $authorizationService->skipAuthorization(); } else { Log::info( diff --git a/tests/TestCase/Controller/DebugKitControllerTest.php b/tests/TestCase/Controller/DebugKitControllerTest.php index 75f51cca..625f8f5a 100644 --- a/tests/TestCase/Controller/DebugKitControllerTest.php +++ b/tests/TestCase/Controller/DebugKitControllerTest.php @@ -66,20 +66,6 @@ private function _buildController() return new DebugKitController($request); } - /** - * tests authorization is enabled but not ignored - * - * @return void - */ - public function testDontIgnoreAuthorization() - { - $controller = $this->_buildController(); - $event = new Event('testing'); - $controller->beforeFilter($event); - - $this->assertFalse($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); - } - /** * tests authorization is checked to avoid * AuthorizationRequiredException throwned From c248890c489f88d72335eafa6613815619437a37 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 14 Nov 2025 04:50:55 +0100 Subject: [PATCH 2/3] Allow debug mode by default. --- src/Controller/DebugKitController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/DebugKitController.php b/src/Controller/DebugKitController.php index e4d7db7c..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') || Configure::read('debug')) { + if (Configure::read('DebugKit.ignoreAuthorization') !== false) { $authorizationService->skipAuthorization(); } else { Log::info( From 2c50292750cc70cd880d953e75ed9faa3dc03378 Mon Sep 17 00:00:00 2001 From: mscherer Date: Fri, 14 Nov 2025 04:53:07 +0100 Subject: [PATCH 3/3] Allow debug mode by default. --- .../Controller/DebugKitControllerTest.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/TestCase/Controller/DebugKitControllerTest.php b/tests/TestCase/Controller/DebugKitControllerTest.php index 625f8f5a..9987e8c3 100644 --- a/tests/TestCase/Controller/DebugKitControllerTest.php +++ b/tests/TestCase/Controller/DebugKitControllerTest.php @@ -74,12 +74,26 @@ private function _buildController() */ public function testIgnoreAuthorization() { - Configure::write('DebugKit.ignoreAuthorization', true); - $controller = $this->_buildController(); $event = new Event('testing'); $controller->beforeFilter($event); $this->assertTrue($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); } + + /** + * tests authorization is enabled but not ignored + * + * @return void + */ + public function testDontIgnoreAuthorization() + { + Configure::write('DebugKit.ignoreAuthorization', false); + + $controller = $this->_buildController(); + $event = new Event('testing'); + $controller->beforeFilter($event); + + $this->assertFalse($controller->getRequest()->getAttribute('authorization')->authorizationChecked()); + } }