Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Saved Queries] Rework saved query privileges #202863

Open
wants to merge 83 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
be94cfe
Remoe saveQueryMenuVisibility
davismcphee Dec 4, 2024
82135fc
Removed unused prop
davismcphee Dec 4, 2024
154ddfa
Deprecate features
davismcphee Dec 4, 2024
dc5dd8b
Map deprecated feature privileges
davismcphee Dec 4, 2024
d7c7492
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 6, 2024
530be40
Update savedQueryManagement read privilege
davismcphee Dec 6, 2024
e283580
Fix reporting privileges
davismcphee Dec 6, 2024
9a7669f
Rename feature_discover to feature_discover_v2
davismcphee Dec 6, 2024
ecbbd1b
Replace feature_visualize with feature_visualize_v2
davismcphee Dec 6, 2024
d9ffd02
Replace feature_dashboard with feature_dashboard_v2
davismcphee Dec 6, 2024
f4300c6
Replace feature_maps with feature_maps_v2
davismcphee Dec 6, 2024
342c0d2
Replace maps UI capabilities with maps_v2
davismcphee Dec 6, 2024
5f1aecf
Replace discover UI capabilities with discover_v2
davismcphee Dec 6, 2024
6462941
Fix types
davismcphee Dec 6, 2024
ecd017a
Replace dashboard UI capabilities with dashboard_v2
davismcphee Dec 6, 2024
c6caf36
Replace visualize UI capabilities with visualize_v2
davismcphee Dec 6, 2024
54530cd
Update serverless roles
davismcphee Dec 7, 2024
c3631a3
Update docs
davismcphee Dec 7, 2024
7438ac2
Fix more capabilities references
davismcphee Dec 7, 2024
7b80270
Fix some Jest tests
davismcphee Dec 7, 2024
eecd961
Try to catch remaining references in CI
davismcphee Dec 7, 2024
c285640
Fix more Jest tests
davismcphee Dec 7, 2024
257aefb
Update capabilitiesProvider return values
davismcphee Dec 9, 2024
ecd00f2
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 9, 2024
d812bf2
Update Capabilities def to try to catch more errors
davismcphee Dec 9, 2024
694988a
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 11, 2024
36785cf
Revert "Update Capabilities def to try to catch more errors"
davismcphee Dec 11, 2024
5492bda
Another shot at catching dangling refs
davismcphee Dec 11, 2024
a4c9658
Fix spaces authorization bug
davismcphee Dec 12, 2024
2cfa7d4
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 12, 2024
08c2e0f
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 12, 2024
9ed56a6
Add minimal replacedBy
davismcphee Dec 12, 2024
adb4b53
Fix issue where Kibana fails to start when there are replacedBy privi…
davismcphee Dec 12, 2024
ae13ef7
Fix issue checking for discover navLink
davismcphee Dec 12, 2024
a4d46f7
Remove v1 privileges saveQuery references
davismcphee Dec 12, 2024
7b4c8e9
Update failing tests
davismcphee Dec 12, 2024
9e38a78
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 12, 2024
ca08ea1
Update Jest snapshots
davismcphee Dec 13, 2024
c0175c9
Fixing functional tests
davismcphee Dec 13, 2024
46a10d1
Revert quote changes in yml files
davismcphee Dec 13, 2024
c399174
Update serverless yml files
davismcphee Dec 13, 2024
3fd0fee
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 13, 2024
dfed85d
Merge branch 'main' into rework-saved-query-privileges
davismcphee Dec 13, 2024
7235ea8
Fix functional tests
davismcphee Dec 13, 2024
e8edb23
Only show saved query management in the UI with savedQueryManagement …
davismcphee Dec 14, 2024
7acd0e2
Update docs and upgrade notes
davismcphee Dec 14, 2024
505cfd7
Fix undefined error and update tests
davismcphee Dec 14, 2024
cdb4da3
Remove .only in test
davismcphee Dec 16, 2024
f4a565a
Merge main, fix conflict
kertal Dec 18, 2024
049f07d
Apply suggestions by @azasypkin
kertal Dec 19, 2024
1eadd4f
Merge branch 'main' into rework-saved-query-privileges
kertal Dec 19, 2024
42bfe4c
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 19, 2024
2a5a720
Merge branch 'main' into rework-saved-query-privileges
kertal Dec 19, 2024
80062a7
Merge remote-tracking branch 'upstream/main' into rework-saved-query-…
kertal Dec 23, 2024
9d693c0
Fix tests
kertal Dec 23, 2024
59a8dca
Merge remote-tracking branch 'upstream/main' into rework-saved-query-…
kertal Dec 27, 2024
2d2c7be
Fix type error
kertal Dec 27, 2024
01354de
Merge remote-tracking branch 'upstream/main' into rework-saved-query-…
kertal Dec 30, 2024
1ac85f5
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 4, 2025
2a1431b
Update initSpacesOnPostAuthRequestInterceptor to use FeaturesPluginSt…
davismcphee Jan 4, 2025
392ee3f
Update deprecated feature display names
davismcphee Jan 4, 2025
9f5d07b
Fix broken type
davismcphee Jan 4, 2025
cc2229f
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 6, 2025
069e8f8
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 10, 2025
ebf724d
Add allowSavingQueries prop to control if queries can be saved
davismcphee Jan 10, 2025
5e78180
Update upgrade notes
davismcphee Jan 10, 2025
2553533
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 13, 2025
a4e9f98
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 16, 2025
d81d900
Fix broken test
davismcphee Jan 16, 2025
01bd64c
Fix test failures
davismcphee Jan 16, 2025
a3cb358
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 16, 2025
7351b70
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine Jan 16, 2025
71282ba
Add feature replacedBy props
davismcphee Jan 17, 2025
587233d
Add functional tests for deprecated features
davismcphee Jan 17, 2025
034c5db
Update yml config
davismcphee Jan 17, 2025
b137d34
Updates snapshot in serverless sec sol authz for deprecated composite…
jeramysoucy Jan 17, 2025
3e0182a
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 17, 2025
9786c73
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 20, 2025
547744d
Revert changes to x-pack/test/functional/es_archives/alerting/8_2_0/d…
davismcphee Jan 20, 2025
1e9dc0d
Fix snapshot
davismcphee Jan 20, 2025
d6fe93d
Merge branch 'main' into rework-saved-query-privileges
davismcphee Jan 20, 2025
3469d55
Fix overrides in serverless.yml
davismcphee Jan 20, 2025
82727a4
Update snapshots
davismcphee Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ xpack.fleet.internal.registry.excludePackages: [
## Fine-tune the search solution feature privileges. Also, refer to `serverless.yml` for the project-agnostic overrides.
xpack.features.overrides:
### Dashboards feature is moved from Analytics category to the Search one.
dashboard.category: "enterpriseSearch"
dashboard_v2.category: "enterpriseSearch"
### Dev Tools feature is moved from Analytics category to the Search one.
dev_tools.category: "enterpriseSearch"
### Discover feature is moved from Analytics category to the Search one.
discover.category: "enterpriseSearch"
discover_v2.category: "enterpriseSearch"
### Machine Learning feature is moved from Analytics category to the Management one.
ml.category: "management"
### Stack Alerts feature is moved from Analytics category to the Search one renamed to simply `Alerts`.
Expand Down Expand Up @@ -130,4 +130,4 @@ xpack.observabilityAIAssistant.scope: "search"
aiAssistantManagementSelection.preferredAIAssistantType: "observability"
xpack.observabilityAiAssistantManagement.logSourcesEnabled: false
xpack.observabilityAiAssistantManagement.spacesEnabled: false
xpack.observabilityAiAssistantManagement.visibilityEnabled: false
xpack.observabilityAiAssistantManagement.visibilityEnabled: false
14 changes: 12 additions & 2 deletions config/serverless.oblt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,20 @@ xpack.features.overrides:
- feature: "observability"
privileges: [ "read" ]
### Dashboards feature should be moved from Analytics category to the Observability one.
dashboard.category: "observability"
dashboard_v2.category: "observability"
### Discover feature should be moved from Analytics category to the Observability one and its privileges are
### fine-tuned to grant access to Observability app.
discover:
privileges:
# Discover `All` feature privilege should implicitly grant `All` access to Observability app.
all.composedOf:
- feature: "observability"
privileges: [ "all" ]
# Discover `Read` feature privilege should implicitly grant `Read` access to Observability app.
read.composedOf:
- feature: "observability"
privileges: [ "read" ]
discover_v2:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally I replaced the existing discover/dashboard/visualize/maps overrides with the v2 features, but I encountered authorization errors in x-pack/test_serverless/functional/test_suites/observability/role_management/custom_role_access.ts for a role with the v1 Discover feature. I'm not sure how this is supposed to work, but it seemed like the overrides weren't applied when the feature was mapped to v2, so I instead duplicated the overrides for v2 features.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, unfortunately, we have to keep the privileges portion of overrides for the deprecated features, as they are still registered and referenced by existing/old roles. However, we can drop the category property.

The confusion probably stems from the fact that roles or privileges are not mutated/migrated in the traditional sense - we keep both old and new features, along with their feature privileges, at the same time. Old roles will continue to refer to the old privileges (unless re-saved by admin), while new roles will refer to the new privileges. We only ensure that the new feature privilege provides at least the same level of access as the deprecated features did.

category: "observability"
privileges:
# Discover `All` feature privilege should implicitly grant `All` access to Observability app.
Expand Down Expand Up @@ -226,4 +236,4 @@ xpack.ml.compatibleModuleType: 'observability'
console.ui.embeddedEnabled: false

# Disable role management (custom roles)
xpack.security.roleManagementEnabled: false
xpack.security.roleManagementEnabled: false
24 changes: 14 additions & 10 deletions config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ xpack.searchIndices.enabled: false
## Fine-tune the security solution feature privileges. Also, refer to `serverless.yml` for the project-agnostic overrides.
xpack.features.overrides:
### Dashboard feature is hidden in Role management since it's automatically granted by SIEM feature.
dashboard.hidden: true
dashboard_v2.hidden: true
### Discover feature is hidden in Role management since it's automatically granted by SIEM feature.
discover.hidden: true
discover_v2.hidden: true
### Machine Learning feature is moved from Analytics category to the Security one as the last item.
ml:
category: "security"
Expand All @@ -29,25 +29,29 @@ xpack.features.overrides:
### Security's `All` feature privilege should implicitly grant `All` access to Discover, Dashboard, Maps, and
### Visualize features.
all.composedOf:
- feature: "discover"
- feature: "discover_v2"
privileges: [ "all" ]
- feature: "dashboard"
- feature: "dashboard_v2"
privileges: [ "all" ]
- feature: "visualize"
- feature: "visualize_v2"
privileges: [ "all" ]
- feature: "maps"
- feature: "maps_v2"
privileges: [ "all" ]
- feature: "savedQueryManagement"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The savedQueryManagement feature was added to siem to avoiding changing the existing behaviour where saved queries are accessible.

privileges: [ "all" ]
# Security's `Read` feature privilege should implicitly grant `Read` access to Discover, Dashboard, Maps, and
# Visualize features. Additionally, it should implicitly grant privilege to create short URLs in Discover,
### Dashboard, and Visualize apps.
read.composedOf:
- feature: "discover"
- feature: "discover_v2"
privileges: [ "read" ]
- feature: "dashboard_v2"
privileges: [ "read" ]
- feature: "dashboard"
- feature: "visualize_v2"
privileges: [ "read" ]
- feature: "visualize"
- feature: "maps_v2"
privileges: [ "read" ]
- feature: "maps"
- feature: "savedQueryManagement"
privileges: [ "read" ]

## Cloud settings
Expand Down
44 changes: 40 additions & 4 deletions config/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,30 @@ xpack.features.overrides:
url_create:
disabled: true
includeIn: "read"
dashboard_v2:
privileges:
### Dashboard's `All` feature privilege should implicitly grant `All` access to Maps and Visualize features.
all.composedOf:
- feature: "maps_v2"
privileges: [ "all" ]
- feature: "visualize_v2"
privileges: [ "all" ]
### Dashboard's `Read` feature privilege should implicitly grant `Read` access to Maps and Visualize features.
### Additionally, it should implicitly grant privilege to create short URLs in Visualize app.
read.composedOf:
- feature: "maps_v2"
privileges: [ "read" ]
- feature: "visualize_v2"
privileges: [ "read" ]
### All Dashboard sub-feature privileges should be hidden: reporting capabilities will be granted via dedicated
### Reporting feature and short URL sub-feature privilege should be granted for both `All` and `Read`.
subFeatures.privileges:
download_csv_report.disabled: true
generate_report.disabled: true
store_search_session.disabled: true
url_create:
disabled: true
includeIn: "read"
discover:
### All Discover sub-feature privileges should be hidden: reporting capabilities will be granted via dedicated
### Reporting feature and short URL sub-feature privilege should be granted for both `All` and `Read`.
Expand All @@ -45,20 +69,32 @@ xpack.features.overrides:
url_create:
disabled: true
includeIn: "read"
discover_v2:
### All Discover sub-feature privileges should be hidden: reporting capabilities will be granted via dedicated
### Reporting feature and short URL sub-feature privilege should be granted for both `All` and `Read`.
subFeatures.privileges:
generate_report.disabled: true
store_search_session.disabled: true
url_create:
disabled: true
includeIn: "read"
### Shared images feature is hidden in Role management since it's not needed.
filesSharedImage.hidden: true
### Maps feature is hidden in Role management since it's automatically granted by Dashboard feature.
maps.hidden: true
maps_v2.hidden: true
### Reporting feature is supposed to give access to reporting capabilities across different features.
reporting:
privileges:
all.composedOf:
- feature: "dashboard"
- feature: "dashboard_v2"
privileges: [ "download_csv_report" ]
- feature: "discover"
- feature: "discover_v2"
privileges: [ "generate_report" ]
### Visualize feature is hidden in Role management since it's automatically granted by Dashboard feature.
visualize:
### The short URL sub-feature privilege should be always granted.
subFeatures.privileges.url_create.includeIn: "read"
visualize_v2:
hidden: true
### The short URL sub-feature privilege should be always granted.
subFeatures.privileges.url_create.includeIn: "read"
Expand Down Expand Up @@ -236,4 +272,4 @@ xpack.dataUsage.enabled: true
xpack.dataUsage.enableExperimental: ['dataUsageDisabled']

# Ensure Serverless is using the Amsterdam theme
uiSettings.experimental.defaultTheme: "amsterdam"
uiSettings.experimental.defaultTheme: "amsterdam"
6 changes: 3 additions & 3 deletions docs/concepts/save-query.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ which include the *Discover* configuration—selected columns in the documen
Discover sessions are primarily used for adding search results to a dashboard.

[role="xpack"]
==== Read-only access
If you have insufficient privileges to save queries,
the *Save* button isn't visible in the saved query management popover.
==== Saved query access
If you have insufficient privileges to manage saved queries,
you will be unable to load or save queries from the saved query management popover.
For more information, see <<xpack-security-authorization, Granting access to Kibana>>

==== Save a query
Expand Down
10 changes: 5 additions & 5 deletions docs/setup/configuring-reporting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ PUT <kibana host>:<port>/api/security/role/custom_reporting_user
"spaces": ["*"],
"base": [],
"feature": {
"dashboard": ["generate_report", <1>
"dashboard_v2": ["generate_report", <1>
"download_csv_report"], <2>
"discover": ["generate_report"], <3>
"discover_v2": ["generate_report"], <3>
"canvas": ["generate_report"], <4>
"visualize": ["generate_report"] <5>
"visualize_v2": ["generate_report"] <5>
}
}]
}
Expand Down Expand Up @@ -146,8 +146,8 @@ PUT localhost:5601/api/security/role/custom_reporting_user
{
"base": [],
"feature": {
"dashboard": [ "all" ], <1>
"discover": [ "all" ], <2>
"dashboard_v2": [ "all" ], <1>
"discover_v2": [ "all" ], <2>
},
"spaces": [ "*" ]
}
Expand Down
17 changes: 17 additions & 0 deletions docs/upgrade-notes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ Upgrade to use the Risk Engine in all spaces which use the legacy risk scoring m
- If the original user and host risk score modules are enabled, you'll see a button to "Start update". Click the button, and follow the instructions.
====

[discrete]
[[breaking-202863]]
.Saved query privileges have been reworked (9.0.0)
[%collapsible]
====
*Details* +
Saved query privileges have been reworked to rely solely on a single global `savedQueryManagement` privilege, and eliminate app-specific overrides (e.g. implicit access with `all` privilege for Discover, Dashboard, Maps, and Visualize apps). This change simplifies the security model and ensures consistency in the saved query management UI across Kibana, but results in different handling of saved query privileges for new user roles, and minor breaking changes to the existing management UX.
For more information, refer to {kibana-pull}202863[#202863].
*Impact* +
The `savedQueryManagement` feature privilege now globally controls access to saved query management for all new user roles. Regardless of privileges for Discover, Dashboard, Maps, or Visualize, new user roles follow this behaviour:
. If `savedQueryManagement` is `none`, the user cannot see or access the saved query management UI or APIs.
. If `savedQueryManagement` is `read`, the user can load queries from the UI and access read APIs, but cannot save queries from the UI or make changes to queries through APIs.
. If `savedQueryManagement` is `all`, the user can both load and save queries from the UI and through APIs.
*Action* +
Existing user roles that were previously implicitly granted access to saved queries through the dashboard, discover, visualize, or maps feature privileges will retain that access to prevent breaking changes. While no action is required for existing roles, it’s still advisable to audit relevant roles and re-save them to migrate to the latest privileges model. For new roles, ensure that the savedQueryManagement privilege is set as needed.
====

[float]
=== Deprecation notices

Expand Down
4 changes: 2 additions & 2 deletions docs/user/security/authorization/kibana-privileges.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ PUT /api/security/role/my_kibana_role
{
"base": [],
"feature": {
"visualize": ["all"],
"dashboard": ["read", "url_create"]
"visualize_v2": ["all"],
"dashboard_v2": ["read", "url_create"]
},
"spaces": ["marketing"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export const App = ({
showSearchBar={true}
indexPatterns={[dataView]}
useDefaultBehaviors={true}
saveQueryMenuVisibility="allowed_by_app_privilege" // allowed only for this example app, use `globally_managed` by default
allowSavingQueries
/>
<EuiPageTemplate.Section>
<EuiText>
Expand Down
Loading