Skip to content

Commit f1d8b81

Browse files
committed
Validate role column config strictly
1 parent 99ffe31 commit f1d8b81

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/Auth/AclTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,12 +552,12 @@ protected function _getUserRoles(ArrayAccess|array $user) {
552552
// Single-role from session
553553
if (!$this->getConfig('multiRole')) {
554554
$roleColumn = $this->getConfig('roleColumn');
555-
if (!$roleColumn) {
555+
if (!is_string($roleColumn) || $roleColumn === '') {
556556
throw new CakeException('Invalid TinyAuth config, `roleColumn` config missing.');
557557
}
558558

559559
// Check if the roleColumn is a dot notation path
560-
if (str_contains((string)$roleColumn, '.')) {
560+
if (str_contains($roleColumn, '.')) {
561561
$role = Hash::get($user, $roleColumn);
562562
if (!$role) {
563563
throw new CakeException(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $roleColumn));

src/Auth/AllowTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function _isActionAllowed(array $rule, $action) {
9797
return false;
9898
}
9999

100-
return !(!in_array($action, $rule['allow'], true) && !in_array('*', $rule['allow'], true));
100+
return in_array($action, $rule['allow'], true) || in_array('*', $rule['allow'], true);
101101
}
102102

103103
/**

0 commit comments

Comments
 (0)