Skip to content

Commit 6d50ac1

Browse files
committed
Force strict equivalence in mongo role checks
1 parent 4920bb6 commit 6d50ac1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/Database/Adapter/Mongo.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ public function find(Document $collection, array $queries = [], ?int $limit = 25
20262026
// permissions
20272027
if ($this->authorization->getStatus()) {
20282028
$roles = \implode('|', $this->authorization->getRoles());
2029-
$filters['_permissions']['$in'] = [new Regex("{$forPermission}\\(\".*(?:{$roles}).*\"\\)", 'i')];
2029+
$filters['_permissions']['$in'] = [new Regex("{$forPermission}\\(\"(?:{$roles})\"\\)", 'i')];
20302030
}
20312031

20322032
$options = [];
@@ -2287,7 +2287,7 @@ public function count(Document $collection, array $queries = [], ?int $max = nul
22872287
// Add permissions filter if authorization is enabled
22882288
if ($this->authorization->getStatus()) {
22892289
$roles = \implode('|', $this->authorization->getRoles());
2290-
$filters['_permissions']['$in'] = [new Regex("read\\(\".*(?:{$roles}).*\"\\)", 'i')];
2290+
$filters['_permissions']['$in'] = [new Regex("read\\(\"(?:{$roles})\"\\)", 'i')];
22912291
}
22922292

22932293
/**
@@ -2377,7 +2377,7 @@ public function sum(Document $collection, string $attribute, array $queries = []
23772377
// permissions
23782378
if ($this->authorization->getStatus()) { // skip if authorization is disabled
23792379
$roles = \implode('|', $this->authorization->getRoles());
2380-
$filters['_permissions']['$in'] = [new Regex("read\\(\".*(?:{$roles}).*\"\\)", 'i')];
2380+
$filters['_permissions']['$in'] = [new Regex("read\\(\"(?:{$roles})\"\\)", 'i')];
23812381
}
23822382

23832383
// using aggregation to get sum an attribute as described in

0 commit comments

Comments
 (0)