Skip to content

Commit 4256b4e

Browse files
committed
fix(proxy): commit on first matching route by path and verb
Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
1 parent f23ebf0 commit 4256b4e

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

lib/Controller/ExAppProxyController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,12 @@ private function buildMultipartFormData(array $bodyParams, array $files): array
312312

313313
private function passesExAppProxyRoutesChecks(ExApp $exApp, string $exAppRoute): array {
314314
foreach ($exApp->getRoutes() as $route) {
315-
if (preg_match('/' . $route['url'] . '/i', $exAppRoute) === 1
315+
$pattern = '~^(?:' . str_replace('~', '\\~', $route['url']) . ')~i';
316+
if (preg_match($pattern, $exAppRoute) === 1
316317
&& str_contains(strtolower($route['verb']), strtolower($this->request->getMethod()))
317-
&& $this->passesExAppProxyRouteAccessLevelCheck($route['access_level'])
318318
) {
319-
return $route;
319+
// First match by path+verb wins. Apply its access level without falling through to broader routes.
320+
return $this->passesExAppProxyRouteAccessLevelCheck($route['access_level']) ? $route : [];
320321
}
321322
}
322323
return [];

lib/Db/ExAppMapper.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function findAll(?int $limit = null, ?int $offset = null): array {
4848
->leftJoin('a', 'ex_apps_daemons', 'd', $qb->expr()->eq('a.daemon_config_name', 'd.name'))
4949
->leftJoin('a', 'ex_apps_routes', 'r', $qb->expr()->eq('a.appid', 'r.appid'))
5050
->orderBy('a.appid', 'ASC')
51+
->addOrderBy('r.id', 'ASC')
5152
->setMaxResults($limit)
5253
->setFirstResult($offset);
5354
return $this->buildExAppWithRoutes($qb->executeQuery()->fetchAll());
@@ -80,6 +81,7 @@ public function findByAppId(string $appId): Entity {
8081
->leftJoin('a', 'ex_apps_daemons', 'd', $qb->expr()->eq('a.daemon_config_name', 'd.name'))
8182
->leftJoin('a', 'ex_apps_routes', 'r', $qb->expr()->eq('a.appid', 'r.appid'))
8283
->orderBy('a.appid', 'ASC')
84+
->addOrderBy('r.id', 'ASC')
8385
->where(
8486
$qb->expr()->eq('a.appid', $qb->createNamedParameter($appId))
8587
);

0 commit comments

Comments
 (0)