Kibana performs the following whenever we need to get the full list of authorized spaces:
- Query ES for all known spaces
- Perform a
_has_privileges check for the current user for all known spaces
- Return a filtered list of spaces that the user is authorized for
This works well enough for a reasonable amount of spaces, but has potential issues when scaling out to a large number of spaces. We should see what performance bottlenecks exist, and if there is anything we can do to optimize this flow.