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

Fleet Privileges Display #204402

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

elena-shostak
Copy link
Contributor

@elena-shostak elena-shostak commented Dec 16, 2024

Summary

Fixed privileges display for features/subFeatures that require all spaces.

Before

Role privileges display for only Default space selected

Screenshot 2024-12-17 at 13 32 17

Privileges summary display for only Default space selected

Screenshot 2024-12-17 at 13 32 50

After

Role privileges display for only Default space selected

Screenshot 2024-12-17 at 13 30 00

Privileges summary display for only Default space selected

Screenshot 2024-12-17 at 13 30 19

How to test

With Default space:

  1. Navigate to Creating a new Role and assign Kibana privileges.
  2. Set the Spaces to Default Space and the privilege level to All.
  3. Navigate to Management category and verify that Fleet is set to None.
  4. Click on "View privilege summary" and verify that Fleet is set to None.

With *All Spaces:

  1. Navigate to Creating a new Role and assign Kibana privileges.
  2. Set the Spaces to *All Spaces and the privilege level to All.
  3. Navigate to Management category and verify that Fleet is set to All
  4. Click on "View privilege summary" and verify that Fleet is set to All

Checklist

Check the PR satisfies following conditions.

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Fixes: #194686

Release Note

Fixed privileges display for features/subFeatures that require all spaces.

@elena-shostak
Copy link
Contributor Author

/ci

1 similar comment
@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak elena-shostak added Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! release_note:fix backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Users/Roles/API Keys labels Dec 17, 2024
@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak elena-shostak marked this pull request as ready for review December 17, 2024 14:44
@elena-shostak elena-shostak requested a review from a team as a code owner December 17, 2024 14:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-security (Team:Security)

@azasypkin azasypkin self-requested a review December 20, 2024 14:37
@azasypkin
Copy link
Member

ACK: will review today, sorry for the delay!

@@ -218,7 +218,7 @@ export class SpaceAwarePrivilegeSection extends Component<Props, State> {
const viewMatrixButton = (
<PrivilegeSummary
role={this.props.role}
spaces={this.getDisplaySpaces()}
spaces={this.getSelectedSpaces()}
Copy link
Member

Choose a reason for hiding this comment

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

Caution

There is something definitely off here when I select different access variations. See the video. Do you see the same?

Screen.Recording.2024-12-24.at.14.16.13.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed, can reproduce, will take a look

Copy link
Contributor Author

Choose a reason for hiding this comment

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

6c631b4 pushed fix, but please hold on review for now, need to check tests

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@azasypkin ready for review 🙂

Copy link
Member

Choose a reason for hiding this comment

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

Nice! I'll review on Monday

Copy link
Member

Choose a reason for hiding this comment

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

It looks like we have another issue now. If Read/All access to Fleet is granted through a Kibana privilege entry with “All Spaces”, the privilege summary for any space-specific privileges should reflect what is granted by the “All Spaces” privilege.

Screen.Recording.2024-12-30.at.16.01.07.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screen.Recording.2024-12-31.at.11.34.58.mov

@azasypkin pushed a fix and checked it with multiple spaces, should work as expected 🙌

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@azasypkin azasypkin self-requested a review December 27, 2024 13:47
@@ -52,7 +52,7 @@ function showPrivilege(allSpacesSelected: boolean, primaryFeature?: PrimaryFeatu
if (
primaryFeature?.name == null ||
primaryFeature?.disabled ||
(primaryFeature.requireAllSpaces && !allSpacesSelected)
(primaryFeature?.requireAllSpaces && !allSpacesSelected)
) {
return 'None';
Copy link
Member

Choose a reason for hiding this comment

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

question: I know it was here before your PR, but shouldn't None be a localized string instead of hardcoded English one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I see we don't localize other privileges as well (Read, All). And some feature/subfeature names.

Screenshot 2024-12-31 at 13 20 24 Screenshot 2024-12-31 at 13 19 57

Copy link
Member

Choose a reason for hiding this comment

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

Interesting, thanks for checking. I wonder if that was a deliberate decision. In any case, it’s outside the scope of this PR.

@@ -210,11 +212,20 @@ export const PrivilegeSummaryTable = (props: PrivilegeSummaryTableProps) => {
</EuiFlexGroup>
);

const categoryPrivileges = Object.keys(privileges).reduce((acc, key) => {
Copy link
Member

Choose a reason for hiding this comment

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

optional nit: since you retrieve value using the key anyway, Object.values might have been a slightly better choice. Or even something like this would be simpler:

const categoryPrivileges = Object.fromEntries(
  Object.entries(privileges).map(([key, [, featurePrivileges]]) => [key, featurePrivileges])
);

@@ -218,7 +218,7 @@ export class SpaceAwarePrivilegeSection extends Component<Props, State> {
const viewMatrixButton = (
<PrivilegeSummary
role={this.props.role}
spaces={this.getDisplaySpaces()}
spaces={this.getSelectedSpaces()}
Copy link
Member

Choose a reason for hiding this comment

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

It looks like we have another issue now. If Read/All access to Fleet is granted through a Kibana privilege entry with “All Spaces”, the privilege summary for any space-specific privileges should reflect what is granted by the “All Spaces” privilege.

Screen.Recording.2024-12-30.at.16.01.07.mov

@elena-shostak elena-shostak force-pushed the 194686-fleet-privileges branch from 64cb61d to 017dad8 Compare December 31, 2024 11:06
@azasypkin azasypkin self-requested a review January 3, 2025 12:35
@elena-shostak elena-shostak force-pushed the 194686-fleet-privileges branch from 017dad8 to ab901f5 Compare January 6, 2025 13:42
Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

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

Looks like we have a new weird behavior 😬

There are so many edge cases, and it’s very tricky to handle them all. It would be even trickier to ensure they aren’t accidentally broken in the future. Thanks for updating the tests to include more cases. We might need to incorporate all these cases into our unit or functional tests, even if they are specifically around Fleet.

Screen.Recording.2025-01-06.at.15.41.15.mov

@elena-shostak elena-shostak force-pushed the 194686-fleet-privileges branch from 45cfb91 to f0c1c9b Compare January 6, 2025 16:03
@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #37 / Observability AI Assistant API tests knowledge_base/knowledge_base_user_instructions.spec.ts Knowledge base user instructions when a user instruction exists and a conversation is created does not add the instruction conversation for other users

Metrics [docs]

Async chunks

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

id before after diff
security 542.2KB 543.3KB +1.1KB
spaces 257.0KB 257.0KB +76.0B
total +1.1KB

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Feature:Users/Roles/API Keys release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Privileges] Discrepancy in display of assigned Kibana Privileges and Privilege summary when creating role
3 participants