Skip to content

Commit 2590556

Browse files
committed
Auth: Merge variable denylists and protections from multiple roles
1 parent b8c33d6 commit 2590556

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
@@ -9,6 +9,14 @@ If you are upgrading across multiple versions, make sure to follow the steps for
99

1010
* The minimum required Icinga Web version is now 2.12.
1111

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

1422
* The routes `users`, `user`, `usergroup` and `usergroups` have been removed.

library/Icingadb/Common/Auth.php

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

122-
$forbiddenVars = Filter::all();
123-
$protectedVars = Filter::any();
124-
$hiddenVars = Filter::any();
122+
$forbiddenVars = Filter::none();
125123
foreach ($this->getAuth()->getUser()->getRoles() as $role) {
126124
if (($restriction = $role->getRestrictions('icingadb/denylist/variables'))) {
127-
$denied = Filter::none();
128-
$hiddenVars->add($denied);
129125
foreach (explode(',', $restriction) as $value) {
130-
$denied->add(Filter::like('name', trim($value))->ignoreCase());
126+
$forbiddenVars->add(Filter::like('name', trim($value))->ignoreCase());
131127
}
132128
}
133129

134130
if (($restriction = $role->getRestrictions('icingadb/protect/variables'))) {
135-
$protected = Filter::none();
136-
$protectedVars->add($protected);
137131
foreach (explode(',', $restriction) as $value) {
138-
$protected->add(Filter::like('name', trim($value))->ignoreCase());
132+
$forbiddenVars->add(Filter::like('name', trim($value))->ignoreCase());
139133
}
140134
}
141135
}
142136

143-
if (! $hiddenVars->isEmpty()) {
144-
$forbiddenVars->add($hiddenVars);
145-
}
146-
147-
if (! $protectedVars->isEmpty()) {
148-
$forbiddenVars->add($protectedVars);
149-
}
150-
151137
if ($forbiddenVars->isEmpty()) {
152138
return;
153139
}
@@ -217,13 +203,14 @@ public function applyRestrictions(Query $query)
217203
$resolver = $query->getResolver();
218204

219205
$queryFilter = Filter::any();
220-
$obfuscationRules = Filter::any();
206+
$forbiddenVars = Filter::all();
207+
$obfuscationRules = Filter::all();
221208
foreach ($this->getAuth()->getUser()->getRoles() as $role) {
222209
$roleFilter = Filter::all();
223210

224211
if ($customVarRelationName !== false) {
225212
if (($restriction = $role->getRestrictions('icingadb/denylist/variables'))) {
226-
$roleFilter->add($this->parseDenylist(
213+
$forbiddenVars->add($this->parseDenylist(
227214
$restriction,
228215
$customVarRelationName
229216
? $resolver->qualifyColumn('flatname', $customVarRelationName)
@@ -358,7 +345,8 @@ public function applyRestrictions(Query $query)
358345
}
359346
}
360347

361-
$query->filter($queryFilter);
348+
$query->filter($queryFilter)
349+
->filter($forbiddenVars);
362350
}
363351
}
364352

0 commit comments

Comments
 (0)