Skip to content

[8.x] 🌊 Streams: Permission handling (#217353)#217520

Merged
flash1293 merged 1 commit intoelastic:8.xfrom
flash1293:backport/8.x/pr-217353
Apr 8, 2025
Merged

[8.x] 🌊 Streams: Permission handling (#217353)#217520
flash1293 merged 1 commit intoelastic:8.xfrom
flash1293:backport/8.x/pr-217353

Conversation

@flash1293
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

Currently, the streams UI doesn't deal well with partial permissions.
This PR improves that. As a lot of things come together in streams, we
could do even better, but I think it's OK to draw a line somewhere.

The logic is now as follows:
When reading a stream, the privileges of the current user are returned
along with the stream itself. These are grouped like this:
```
interface IngestStreamPrivileges {
  // User can change everything about the stream
  manage: boolean;
  // User can read stats (like size in bytes) about the stream
  monitor: boolean;
  // User can change the retention policy of the stream
  lifecycle: boolean;
  // User can simulate changes to the processing or the mapping of the stream
  simulate: boolean;
}
```

This is part of the definition response and is passed around to the
components and disabled buttons and similar in the places where this is
necessary.

The "advanced" tab is only shown when full `manage` permissions are
present - there constellations of permissions that would allow some
access but not all (e.g. having `read_pipelines` but not
`manage_index_templates`), but these should be rather rare and not worth
the additional effort.

## Conditions

In the following places privileges are checked:
* Overview
  * Without `monitor`, the overall stats are not shown
* Enrichment
  * Without `manage`, you can't save changes
  * Without `simulate`, the UI is readonly
* Partitioning
  * Without `manage`, you can't save changes
  * Without `simulate`, the UI is readonly
* Schema editor
  * Without `manage`, the UI is readonly
* Retention
  * Without `monitor`, the ingest stats are not shown
* Without `lifecycle`, the retention can't be changed and ILM breakdown
is not rendered
* Advanced
  * Without `manage`, the tab is hidden completely

## Drive-by fix

I noticed that we still register the app header action menu which adds
an empty bar on serverless, removed that code.

## Testing

Check
https://github.com/elastic/kibana/pull/217353/files#diff-d8f33d7021058bf90cbeea908bf399da2af50d8b8bfac8a07f160ddc0cdff12bR747
for which Elasticsearch level privileges you need for different
permutations. Then set up a role and a user and log in as that user.

Also test the different pre-defined roles on serverless.

(cherry picked from commit fd37446)

# Conflicts:
#	x-pack/platform/plugins/shared/streams/server/routes/streams/crud/read_stream.ts
@flash1293 flash1293 requested a review from kibanamachine as a code owner April 8, 2025 13:51
@flash1293 flash1293 added the backport This PR is a backport of another PR label Apr 8, 2025
@flash1293 flash1293 enabled auto-merge (squash) April 8, 2025 13:52
@flash1293 flash1293 merged commit eba8935 into elastic:8.x Apr 8, 2025
11 checks passed
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #65 / discover/group4 adhoc data views should support query and filtering
  • [job] [logs] FTR Configs #55 / Observability Logs Explorer DataSourceSelector with installed integrations and uncategorized data streams when open on the integrations tab should display a list of installed integrations

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
streamsApp 443 441 -2

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/streams-schema 353 355 +2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
streamsApp 428.4KB 426.8KB -1.7KB
Unknown metric groups

API count

id before after diff
@kbn/streams-schema 367 369 +2

async chunk count

id before after diff
streamsApp 9 8 -1

ESLint disabled line counts

id before after diff
streamsApp 7 6 -1

References to deprecated APIs

id before after diff
streamsApp 4 2 -2

Total ESLint disabled count

id before after diff
streamsApp 11 10 -1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants