Skip to content

Commit

Permalink
Apply restrictions to model queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoxhaa committed Dec 17, 2024
1 parent bf5c40a commit 6aa37b4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion library/Kubernetes/Dashboard/IcingaStateDashlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Kubernetes\Dashboard;

use Icinga\Module\Kubernetes\Common\Auth;
use Icinga\Module\Kubernetes\Common\Database;
use Icinga\Module\Kubernetes\Web\Factory;
use Icinga\Web\Session;
Expand All @@ -15,7 +16,11 @@ class IcingaStateDashlet extends Dashlet
{
protected function getIcingaStateCounts(): array
{
$q = (Factory::createModel($this->kind)::on(Database::connection()));
$q = Auth::getInstance()
->withRestrictions(
Auth::PERMISSIONS[$this->kind],
Factory::createModel($this->kind)::on(Database::connection())
);

$clusterUuid = Session::getSession()->getNamespace('kubernetes')->get('cluster_uuid');
if ($clusterUuid !== null) {
Expand Down
7 changes: 6 additions & 1 deletion library/Kubernetes/Dashboard/KubernetesPhaseDashlet.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Kubernetes\Dashboard;

use Icinga\Module\Kubernetes\Common\Auth;
use Icinga\Module\Kubernetes\Common\Database;
use Icinga\Module\Kubernetes\Web\Factory;
use Icinga\Web\Session;
Expand All @@ -15,7 +16,11 @@ class KubernetesPhaseDashlet extends Dashlet
{
protected function getKubernetesPhaseCounts(): array
{
$q = (Factory::createModel($this->kind)::on(Database::connection()));
$q = Auth::getInstance()
->withRestrictions(
Auth::PERMISSIONS[$this->kind],
Factory::createModel($this->kind)::on(Database::connection())
);

$clusterUuid = Session::getSession()->getNamespace('kubernetes')->get('cluster_uuid');
if ($clusterUuid !== null) {
Expand Down

0 comments on commit 6aa37b4

Please sign in to comment.