TL;DR
What’s an easy way to deny users access to multiple index patterns?
Implementation Details
- Elasticsearch/Kibana: 7.8.0 (official Elastic Docker images, with Search Guard installed)
- Search Guard: 43.0.0
Question
According to the Search Guard documentation, index permissions can be granted to users based on regular expressions, which makes the following permissions grant possible, giving the ability to read all indices except for myapp-*
:
# Grant read access on all indices except for those matching
# regex pattern.
READALL_EXCEPT:
reserved: false
hidden: false
description: 'Grant RO access to indices for users.'
cluster_permissions:
- 'SGS_CLUSTER_COMPOSITE_OPS_RO'
index_permissions:
- index_patterns:
- '/^(?!myapp-)\S*$/'
fls: []
masked_fields: []
allowed_actions:
- 'SGS_READ'
tenant_permissions: []
static: false
We primarily use our Elastic Stack for log aggregation, so our permission structure in Elastic is permissive: We grant all users the ability to view all data unless there is a specific reason to exclude them from viewing that data (i.e., certain applications). In our environment, there are multiple applications, which need to have data restricted. When using the pattern above, this can end up creating a very long regex, and can be a little tricky to create in the Kibana Search Guard UI:
# Grant read access on all indices except for those matching
# regex pattern.
READALL_EXCEPT:
reserved: false
hidden: false
description: 'Grant RO access to indices for users.'
cluster_permissions:
- 'SGS_CLUSTER_COMPOSITE_OPS_RO'
index_permissions:
- index_patterns:
- '/^(?!first-app-|second-app-|third-app-|fourth-app-)\S*$/'
fls: []
masked_fields: []
allowed_actions:
- 'SGS_READ'
tenant_permissions: []
static: false
Is there any way to simplify this without having to specifically add each index to the allow list? I.e., I note that index_patterns
is a list. Does SG process these in order, to look for the first match, or does it look for any match? For example, would the following index_permissions
specification allow or deny access to the third-app-*
index pattern?
index_permissions:
- index_patterns:
- '/^(?!first-app-)\S*$/'
- '/^(?!second-app-)\S*$/'
- '/^(?!third-app-)\S*$/'
- '/^(?!fourth-app-)\S*$/'
- '*' # Match all other index patterns.
From the design of the Kibana Search Guard UI, I’m guessing the answer is “no,” but I’m hoping. If that doesn’t work, is there an alternate way to accomplish the same thing without either having the super-long index pattern or having to individually add indices to the allow list?