Skip to content

Commit b95762e

Browse files
jpipkin1kimsauce
andauthored
DOCS-680 - Update role filtering guidance on "role stacking" (#5049)
* DOCS-680 - Update role filter article * Update docs/manage/users-roles/roles/construct-search-filter-for-role.md Co-authored-by: Kim (Sumo Logic) <[email protected]> * Update docs/manage/users-roles/roles/create-manage-roles.md Co-authored-by: Kim (Sumo Logic) <[email protected]> * Update docs/reuse/role-stacking-tip.md Co-authored-by: Kim (Sumo Logic) <[email protected]> * Updates from reviews --------- Co-authored-by: Kim (Sumo Logic) <[email protected]>
1 parent 7e0e4b0 commit b95762e

File tree

6 files changed

+69
-65
lines changed

6 files changed

+69
-65
lines changed

docs/manage/users-roles/roles/construct-search-filter-for-role.md

Lines changed: 37 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,20 @@ description: Construct a role search filter to control what log data users with
55
---
66

77
import useBaseUrl from '@docusaurus/useBaseUrl';
8-
8+
import RoleStacking from '../../../reuse/role-stacking-tip.md';
99

1010
This page describes how to define search filters for a role. These instructions apply to the **Search Filter** option in Step 6 of the [Create a role](/docs/manage/users-roles/roles/create-manage-roles/#create-a-role) procedure.
11-
12-
## Understanding search filters
13-
14-
A search filter for a role defines what log data a user with that role can access. You can define a search filter using keywords, wildcards, metadata fields, and logical operators. Here is a simple role filter:
15-
16-
```sql
17-
_sourceCategory=labs*
18-
```
19-
20-
This filter grants access to logs whose `_sourceCategory` begins with the string “labs”. (Logs whose `_sourceCategory` don’t start with “labs” won’t be accessible.)
21-
22-
When a user with this filter enters a query like:
23-
24-
```sql
25-
_sourceCategory=labs/apache | parse "* --" as src_ip | count by src_ip | sort _count
26-
```
27-
28-
Sumo silently (it’s transparent to the user) adds the role filter to the beginning of the query with an AND:
29-
30-
```sql
31-
_sourceCategory=labs* AND (_sourceCategory=labs/apache | parse "* --" as src_ip | count by src_ip | sort _count)
32-
```
33-
34-
The example above positively grants access to log data. You can do the opposite: explicitly deny access to data, with an exclamation point (!). For example:
35-
36-
```
37-
!_sourceCategory=JobX*
38-
```
39-
40-
The role filter above denies access to log data whose  `_sourceCategory` begins with “JobX”. (Access to log data with other source category values is not restricted.)
41-
42-
The examples above are simple: they involve a single role, and hence a single role filter. 
43-
44-
Typically however, a Sumo user will have multiple roles. If a user has multiple roles, Sumo `OR`s the several role filters and prepends that expression to the user’s queries with an `AND`, as discussed in [Multiple role filters and filter precedence](#multiple-role-filters-and-filter-precedence).
4511

4612
## Search filter basics
4713

48-
The sections below list search filter limitations, and describe how you can use keywords, wildcards, metadata, and logical operators in filters. 
14+
A search filter for a role defines what log data a user with that role can access. You can define a search filter using keywords, wildcards, metadata fields, and logical operators.
4915

50-
The explanations of the behavior of each example filter assume that no other role filters apply. In practice, you will likely assign multiple roles to users. After you understand the basics of how role filters work, see [Multiple role filters and filter precedence](#multiple-role-filters-and-filter-precedence).
16+
The explanations of the behavior of each example filter assume that no other role filters apply. In practice, you may assign multiple roles to users. After you understand the basics of how role filters work, see [Multiple role filters and filter precedence](#multiple-role-filters-and-filter-precedence).
5117

5218
### Search filter limitations
5319

20+
The sections below list search filter limitations, and describe how you can use keywords, wildcards, metadata, and logical operators in filters. 
21+
5422
* Role filters should include only keyword expressions or built-in metadata field expressions using these fields: `_sourcecategory`, `_collector`, `_source`, `_sourcename`, `_sourcehost`.
5523
* Using `_index` or `_view` in a role filter scope is not supported.
5624
* Role filters cannot include vertical pipes (`|`).
@@ -69,33 +37,33 @@ You can use metadata fields in a role search filter. The following search filter
6937
_collector=HR_Tools
7038
```
7139

72-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
40+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
7341

7442
```sql
7543
_collector=HR_Tools AND <user-query>
7644
```
7745

7846
### Using AND and OR in a search filter
7947

80-
You can use AND and OR in a search filter. For example, this role filter uses OR to grant access to log data from two source categories:
48+
You can use `AND` and `OR` in a search filter. For example, this role filter uses `OR` to grant access to log data from two source categories:
8149

8250
```sql
8351
_sourceCategory=stock OR _sourceCategory=insurance
8452
```
8553

86-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
54+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
8755

8856
```sql
8957
(_sourceCategory=stock OR _sourceCategory=insurance) AND <user-query>
9058
```
9159

92-
This role filter below uses AND to grant access to log data with the source category “insurance” from the collector named “HR_Tools”:
60+
This role filter below uses `AND` to grant access to log data with the source category “insurance” from the collector named “HR_Tools”:
9361

9462
```sql
9563
_collector=HR_Tools AND _sourceCategory=insurance
9664
```
9765

98-
When a user with that role filter runs a query, Sumo prepends the filter to the query with an AND:
66+
When a user with that role filter runs a query, Sumo Logic prepends the filter to the query with an `AND`:
9967

10068
```sql
10169
(_collector=HR_Tools AND _sourceCategory=insurance) AND <user-query>
@@ -109,7 +77,7 @@ You can include a string you want to search for in a role search filter. This ro
10977
_collector=HR_Tools AND enrollment
11078
```
11179

112-
When a user with that role filter runs a query, Sumo runs it like this:
80+
When a user with that role filter runs a query, Sumo Logic runs it like this:
11381

11482
```sql
11583
(_collector=HR_Tools AND enrollment) AND <user-query>
@@ -123,7 +91,7 @@ You can use an asterisk (\*) as a wildcard in a role search filter. This role fi
12391
_collector=HR* 
12492
```
12593

126-
When a user with that role filter runs a query, Sumo runs it like this:
94+
When a user with that role filter runs a query, Sumo Logic runs it like this:
12795

12896
```sql
12997
_collector=HR* AND <user-query>
@@ -135,7 +103,7 @@ This role filter grants access to logs that contain the string “violation” f
135103
_collector=HR* AND violation
136104
```
137105

138-
When a user with that role filter runs a query, Sumo runs it like this:
106+
When a user with that role filter runs a query, Sumo Logic runs it like this:
139107

140108
```sql
141109
(_collector=HR* AND violation) AND <user-query>
@@ -155,15 +123,21 @@ denies access to log data whose:  
155123
* `_sourceName` contains “finance”
156124
* `_sourceCategory` contains “secret”
157125

158-
When a user with that role filter runs a query, Sumo runs it like this:
126+
When a user with that role filter runs a query, Sumo Logic runs it like this:
159127

160128
```sql
161129
(!_sourceHost=humanresources* AND !_sourceName=*finance* AND !_sourceCategory=*secret*) AND <your-query>
162130
```
163131

132+
:::warning
133+
Although this example demonstrates that filtering to deny access is possible, we do not recommend it. If a user has multiple roles, one role may deny access to an area while another grants access, leading to conflicts. To avoid this, use filtering to allow access rather than deny it. This ensures roles work additively, making access management more predictable.
134+
:::
135+
164136
## Multiple role filters and filter precedence
165137

166-
When a user is assigned to multiple Sumo roles, Sumo combines the role filters from each of the roles using a logical OR to come up with the combined role filter.
138+
When a user is assigned to multiple Sumo Logic roles ("role stacking"), Sumo Logic combines the role filters from each of the roles using a logical `OR` to come up with the combined role filter.
139+
140+
<RoleStacking/>
167141

168142
When multiple roles filters are applied to a query, the least restrictive filter takes precedence. That this rule doesn’t apply if any of the role filters applied to a query is simply blank, which effectively grants access to all data, and would be the least restrictive filter. If the combined search filters applied to a query includes filters that are blank, the blank search filter is ignored and the next least restrictive filter takes precedence. So, if you actually want to grant a role access to all data, set the search filter to an asterisk (`*`). A search filter that is configured in that fashion will take precedence when combined with more restrictive search filters.
169143

@@ -180,7 +154,7 @@ Role A allows access to log data whose `_source` tag is “GCP Audit” and `_co
180154

181155
Role B Allows access to log data whose `_sourceCategory` tag begins with “Vx”.  
182156

183-
When a user with Roles A and B runs a query, Sumo applies the filters with an OR, and prepends them with an AND to your query, like this:
157+
When a user with Roles A and B runs a query, Sumo Logic applies the filters with an `OR`, and prepends them with an `AND` to your query, like this:
184158

185159
```sql
186160
((_source="GCP Audit" AND _collector="GCP") OR _sourceCategory="Vx*")
@@ -196,19 +170,19 @@ Assume the following role filters.
196170
| Role | Filter |
197171
|:----------|:-------------------|
198172
| Role A | `_collector=fee*` |
199-
| Role B | `!_collector=fi*` |
173+
| Role B | `_collector=f*` |
200174

201175
Role A allows access only to log data whose `_collector` tag matches “fee\*”, and not to data whose `_collector` tag is any other value.
202176

203-
Role B Allows access to any log data whose `_collector` tag does not match “fi”.  
177+
Role B Allows access to any log data whose `_collector` tag matches “f\*”, and not to data whose `_collector` tag is any other value.  
204178

205-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, and prepends them with an AND to your query, like this:
179+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, and prepends them with an `AND` to your query, like this:
206180

207181
```sql
208-
(_collector=fee OR !_collector=fi) AND <your-query>
182+
(_collector=fee OR _collector=f) AND <your-query>
209183
```
210184

211-
**The least restrictive of the role filters takes precedence**. So, although Role A effectively restricts results to log data that matches `_collector=fee*`, Role B allows grants access to all collectors, except for those that match `_collector=fi*`. So, Role B takes precedence and Role A has no effect.
185+
**The least restrictive of the role filters takes precedence**. So, although Role A effectively restricts results to log data that matches `_collector=fee*`, Role B allows grants access to all collectors that match `_collector=f*`. So, Role B takes precedence and Role A has no effect.
212186

213187
### Example 3 
214188

@@ -224,14 +198,15 @@ Role A allows access only to log data whose `_sourceCategory` is “analytics-la
224198

225199
Role B Allows access to log data whose `_sourceCategory` begins with “analytics”.
226200

227-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, like this:
201+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, like this:
228202

229203
```sql
230204
(_sourceCategory=analytics-lab OR _sourceCategory=analytics*) AND <your-query>
231205
```
232206

233207
**The least restrictive of the role filters takes precedence.** Role A alone grants access to a log data from a single  source category, “analytics-lab”.  Role B grants access to log data to any source category that starts with “analytics”. Since the least restrictive filter takes precedence, data tagged `_sourceCategory=analyticsLong` could be returned in addition to data tagged `_sourceCategory=analytics-lab`.
234208

209+
<!-- Hiding the following for work on DOCS-680
235210
### Example 4
236211
237212
Assume the following role filters.
@@ -245,15 +220,16 @@ Role A allows access to log data whose `_collector` tag matches “prod\*”, an
245220
246221
Role B prevents access to log data whose `_sourceCategory` tag does contain “shoguns”. Data with any ` _sourceCategory` tag that does not contain “shoguns” is available. 
247222
248-
When a user with Roles A and B runs a query, Sumo combines the two filters with an OR, and prepends them with an AND to your query, like this:
223+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters with an `OR`, and prepends them with an `AND` to your query, like this:
249224
250225
```sql
251226
(_collector=prod* OR !_sourceCategory=*shoguns*) AND <your-query>
252227
```
253228
254229
Role B is the least restrictive. Users with the combined role filter will be able to view any log data whose  `_sourceCategory` does not contain the string “shoguns”, regardless of the value of the `_collector` tag.
230+
-->
255231

256-
### Example 5
232+
### Example 4
257233

258234
Assume the following role filters.
259235

@@ -266,4 +242,8 @@ Role A allows access to all indexes whose name starts with "sumologic".
266242

267243
Role B, with a blank search filter (user did not enter anything as the search filter for the role), allows access to all data.
268244

269-
When a user with Roles A and B runs a query, Sumo combines the two filters and since Role B has a blank search filter, the more restrictive search filter, Role A, takes precedence. Users with the combined role filter will be able to  view any log data in any of the indexes prefixed with "sumologic".
245+
When a user with Roles A and B runs a query, Sumo Logic combines the two filters and since Role B has a blank search filter, the more restrictive search filter, Role A, takes precedence. Users with the combined role filter will be able to  view any log data in any of the indexes prefixed with "sumologic".
246+
247+
## Test role filtering
248+
249+
To test whether filtering works as expected, select a role and click the **Emulate log search** button. For more information, see [Test a role](/docs/manage/users-roles/roles/create-manage-roles/#test-a-roles-log-access-rights).

0 commit comments

Comments
 (0)