Skip to content

Commit 7ae8707

Browse files
committed
Fix up authorization plugin support
1 parent 10e3bfb commit 7ae8707

16 files changed

+31
-32
lines changed

config/auth_acl.default.ini

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
; If you use plugins like dereuromark/cakephp-databaselog
2-
[DatabaseLog.admin/DatabaseLog]
2+
[DatabaseLog.Admin/DatabaseLog]
33
* = admin
4-
[DatabaseLog.admin/Logs]
4+
[DatabaseLog.Admin/Logs]
55
* = admin
66

77
; If you use dereuromark/cakephp-queue
8-
[Queue.admin/Queue]
8+
[Queue.Admin/Queue]
99
* = admin
10-
[Queue.admin/QueuedJobs]
10+
[Queue.Admin/QueuedJobs]
1111
* = admin
12-
[Queue.admin/QueueProcesses]
12+
[Queue.Admin/QueueProcesses]
1313
* = admin
14-
15-
; ...

config/auth_allow.default.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Users = login,logout
88
DebugKit.Dashboard = *
99
DebugKit.Requests = *
1010
DebugKit.Panels = *
11+
DebugKit.Toolbar = *
1112

1213
; If you use cakedc/mixer as require-dev
1314
CakeDC/Mixer.Mixer

docs/AuthorizationPlugin.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $middlewareQueue->add(new AuthorizationMiddleware($this, [
2626
]));
2727
$middlewareQueue->add(new RequestAuthorizationMiddleware([
2828
'unauthorizedHandler' => [
29-
'className' => 'TinyAuth.Redirect',
29+
'className' => 'TinyAuth.ForbiddenRedirect',
3030
'url' => '...',
3131
'unauthorizedMessage' => '...',
3232
],

src/Auth/AclAdapter/AclAdapterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface AclAdapterInterface {
88
* Generates and returns a TinyAuth access control list.
99
*
1010
* @param array $availableRoles A list of available user roles.
11-
* @param array $config Current TinyAuth configuration values.
11+
* @param array<string, mixed> $config Current TinyAuth configuration values.
1212
*
1313
* @return array
1414
*/

src/Auth/AclTrait.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ protected function _loadAclAdapter($adapter) {
8383
*
8484
* Allows single or multi role based authorization
8585
*
86-
* @param array $user User data
87-
* @param array $params Request params
86+
* @param array<string, mixed> $user User data
87+
* @param array<string, mixed> $params Request params
8888
* @throws \Cake\Core\Exception\CakeException
8989
* @return bool Success
9090
*/
@@ -110,7 +110,7 @@ protected function _checkUser(array $user, array $params) {
110110
}
111111
}
112112

113-
// Give any logged in user access to ALL actions when `allowLoggedIn` is
113+
// Give any logged-in user access to ALL actions when `allowLoggedIn` is
114114
// enabled except when the `protectedPrefix` is being used.
115115
if ($this->getConfig('allowLoggedIn')) {
116116
if (empty($params['prefix'])) {
@@ -516,7 +516,7 @@ protected function _getRolesFromDb(string $rolesTableKey): array {
516516
* @throws \Cake\Core\Exception\CakeException
517517
* @return array<string, int|string> List with all role ids belonging to the user
518518
*/
519-
protected function _getUserRoles($user) {
519+
protected function _getUserRoles(array $user) {
520520
// Single-role from session
521521
if (!$this->getConfig('multiRole')) {
522522
$roleColumn = $this->getConfig('roleColumn');
@@ -531,7 +531,9 @@ protected function _getUserRoles($user) {
531531
return [];
532532
}
533533

534-
return $this->_mapped([$user[$this->getConfig('roleColumn')]]);
534+
$role = $user[$this->getConfig('roleColumn')];
535+
536+
return $this->_mapped([$role]);
535537
}
536538

537539
// Multi-role from session

src/Auth/TinyAuthorize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TinyAuthorize extends BaseAuthorize {
3131

3232
/**
3333
* @param \Cake\Controller\ComponentRegistry $registry
34-
* @param array $config
34+
* @param array<string, mixed> $config
3535
* @throws \Cake\Core\Exception\CakeException
3636
*/
3737
public function __construct(ComponentRegistry $registry, array $config = []) {

src/Controller/Component/AuthComponent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AuthComponent extends LegacyAuthComponent {
2020

2121
/**
2222
* @param \Cake\Controller\ComponentRegistry $registry
23-
* @param array $config
23+
* @param array<string, mixed> $config
2424
* @throws \RuntimeException
2525
*/
2626
public function __construct(ComponentRegistry $registry, array $config = []) {
@@ -39,7 +39,7 @@ public function __construct(ComponentRegistry $registry, array $config = []) {
3939
}
4040

4141
/**
42-
* @param array $config The config data.
42+
* @param array<string, mixed> $config The config data.
4343
* @return void
4444
*/
4545
public function initialize(array $config): void {

src/Controller/Component/AuthUserComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AuthUserComponent extends Component {
2121

2222
/**
2323
* @param \Cake\Controller\ComponentRegistry $registry
24-
* @param array $config
24+
* @param array<string, mixed> $config
2525
*/
2626
public function __construct(ComponentRegistry $registry, array $config = []) {
2727
$config += Config::all();

src/Controller/Component/AuthenticationComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AuthenticationComponent extends CakeAuthenticationComponent {
2424

2525
/**
2626
* @param \Cake\Controller\ComponentRegistry $registry
27-
* @param array $config
27+
* @param array<string, mixed> $config
2828
* @throws \RuntimeException
2929
*/
3030
public function __construct(ComponentRegistry $registry, array $config = []) {

src/Controller/Component/AuthorizationComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class AuthorizationComponent extends CakeAuthorizationComponent {
2929

3030
/**
3131
* @param \Cake\Controller\ComponentRegistry $registry
32-
* @param array $config
32+
* @param array<string, mixed> $config
3333
* @throws \RuntimeException
3434
*/
3535
public function __construct(ComponentRegistry $registry, array $config = []) {

0 commit comments

Comments
 (0)