Skip to content

Commit 22e1aef

Browse files
committed
Auth: Merge variable denylists and protections from multiple roles
1 parent c7cc328 commit 22e1aef

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

doc/04-Security.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@ Denylists prevent users from accessing information and in some cases will block
6969
>
7070
> Denylists from multiple roles will further limit access.
7171
72-
Name | Description
73-
-----------------------------|------------------------------------------------------------------
74-
icingadb/denylist/routes | Prevent access to routes that are part of the list
75-
icingadb/denylist/variables | Hide custom variables of Icinga objects that are part of the list
72+
| Name | Description |
73+
|-----------------------------|-------------------------------------------------------------------|
74+
| icingadb/denylist/routes | Prevent access to routes that are part of the list |
75+
| icingadb/denylist/variables | Hide custom variables of Icinga objects that are part of the list |
7676

7777
`icingadb/denylist/routes` will block users from accessing defined routes and from related information elsewhere.
7878
For example, if `hostgroups` are part of the list a user won't have access to the hostgroup overview nor to a host's
79-
groups shown in its detail area. This should be a comma separated list. Possible values are: hostgroups, servicegroups,
79+
groups shown in its detail area. This should be a comma-separated list. Possible values are: hostgroups, servicegroups,
8080
contacts, contactgroups
8181

8282
`icingadb/denylist/variables` will block users from accessing certain custom variables. A user affected by this won't
83-
see that those variables even exist. This should be a comma separated list of [variable paths](#variable-paths). It is
83+
see that those variables even exist. This should be a comma-separated list of [variable paths](#variable-paths). It is
8484
possible to use [match patterns](#match-patterns).
8585

8686
### Protections
@@ -91,12 +91,12 @@ Protections prevent users from accessing actual data. They will know that there
9191
>
9292
> Denylists from multiple roles will further limit access.
9393
94-
Name | Description
95-
---------------------------|-----------------------------------------------------------------------------
96-
icingadb/protect/variables | Obfuscate custom variable values of Icinga objects that are part of the list
94+
| Name | Description |
95+
|----------------------------|------------------------------------------------------------------------------|
96+
| icingadb/protect/variables | Obfuscate custom variable values of Icinga objects that are part of the list |
9797

9898
`icingadb/protect/variables` will replace certain custom variable values with `***`. A user affected by this will still
99-
be able to see the variable names though. This should be a comma separated list of [variable paths](#variable-paths).
99+
be able to see the variable names, though. This should be a comma-separated list of [variable paths](#variable-paths).
100100
It is possible to use [match patterns](#match-patterns).
101101

102102
### Formats

doc/05-Upgrading.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ If you are upgrading across multiple versions, make sure to follow the steps for
55

66
## Upgrading to Icinga DB Web v1.3
77

8+
**Breaking Changes**
9+
10+
* The restrictions `icingadb/denylist/variables` and `icingadb/protect/variables` from different roles are now
11+
merged into a single list, respectively. This means that variables denied in one role will not show up anymore
12+
if another role denies access to different variables. The same applies to `icingadb/protect/variables`, in which
13+
case variables protected in one role will now be protected even if another role protects different variables.
14+
This has been done to simplify the configuration and to get it more in line with how refusals work in Icinga Web.
15+
816
**Removed Features**
917

1018
* The migration widget in the top right has been removed. If you have not adjusted your navigation items,

library/Icingadb/Common/Auth.php

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,35 +125,21 @@ public function assertColumnRestrictions(Filter\Rule $filter): void
125125
return;
126126
}
127127

128-
$forbiddenVars = Filter::all();
129-
$protectedVars = Filter::any();
130-
$hiddenVars = Filter::any();
128+
$forbiddenVars = Filter::none();
131129
foreach ($this->getAuth()->getUser()->getRoles() as $role) {
132130
if (($restriction = $role->getRestrictions('icingadb/denylist/variables'))) {
133-
$denied = Filter::none();
134-
$hiddenVars->add($denied);
135131
foreach (explode(',', $restriction) as $value) {
136-
$denied->add(Filter::like('name', trim($value))->ignoreCase());
132+
$forbiddenVars->add(Filter::like('name', trim($value))->ignoreCase());
137133
}
138134
}
139135

140136
if (($restriction = $role->getRestrictions('icingadb/protect/variables'))) {
141-
$protected = Filter::none();
142-
$protectedVars->add($protected);
143137
foreach (explode(',', $restriction) as $value) {
144-
$protected->add(Filter::like('name', trim($value))->ignoreCase());
138+
$forbiddenVars->add(Filter::like('name', trim($value))->ignoreCase());
145139
}
146140
}
147141
}
148142

149-
if (! $hiddenVars->isEmpty()) {
150-
$forbiddenVars->add($hiddenVars);
151-
}
152-
153-
if (! $protectedVars->isEmpty()) {
154-
$forbiddenVars->add($protectedVars);
155-
}
156-
157143
if ($forbiddenVars->isEmpty()) {
158144
return;
159145
}
@@ -223,13 +209,14 @@ public function applyRestrictions(Query $query)
223209
$resolver = $query->getResolver();
224210

225211
$queryFilter = Filter::any();
226-
$obfuscationRules = Filter::any();
212+
$forbiddenVars = Filter::all();
213+
$obfuscationRules = Filter::all();
227214
foreach ($this->getAuth()->getUser()->getRoles() as $role) {
228215
$roleFilter = Filter::all();
229216

230217
if ($customVarRelationName !== false) {
231218
if (($restriction = $role->getRestrictions('icingadb/denylist/variables'))) {
232-
$roleFilter->add($this->parseDenylist(
219+
$forbiddenVars->add($this->parseDenylist(
233220
$restriction,
234221
$customVarRelationName
235222
? $resolver->qualifyColumn('flatname', $customVarRelationName)
@@ -364,7 +351,8 @@ public function applyRestrictions(Query $query)
364351
}
365352
}
366353

367-
$query->filter($queryFilter);
354+
$query->filter($queryFilter)
355+
->filter($forbiddenVars);
368356
}
369357
}
370358

0 commit comments

Comments
 (0)