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

[Roles] Added transformation of application * privilege to all #181400

Merged
merged 14 commits into from
Apr 30, 2024

Conversation

elena-shostak
Copy link
Contributor

@elena-shostak elena-shostak commented Apr 23, 2024

Summary

Added transformation of application wildcard * privilege to all to correctly filter and display roles as superuser.

[Screenshot] Kibana superuser role before change Screenshot 2024-04-23 at 11 20 31
[Screenshot] Kibana superuser role after change Screenshot 2024-04-23 at 11 17 54

Checklist

For maintainers

Fixes: #106561

Release note

Added transformation of application wildcard * privilege to all to correctly filter and display roles as superuser.

@elena-shostak elena-shostak added bug Fixes for quality problems that affect the customer experience Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! Feature:Users/Roles/API Keys labels Apr 23, 2024
@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak elena-shostak marked this pull request as ready for review April 23, 2024 11:28
@elena-shostak elena-shostak requested a review from a team as a code owner April 23, 2024 11:28
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

Nice work, Elena!

I just found one issue. If I create a role via ES API with wildcard application privileges (like superuser and system_indices_superuser both have), and then load and save the role in the UI (making no changes), the role ends up with an additional entry that correlates to the translated 'all' privilege.

"applications": [
    {
        "application": "*",
        "privileges": [
            "*"
        ],
        "resources": [
            "*"
        ]
    }
],

becomes

"applications": [
    {
        "application": "kibana-.kibana",
        "privileges": [
            "all"
        ],
        "resources": [
            "*"
        ]
    },
    {
        "application": "*",
        "privileges": [
            "*"
        ],
        "resources": [
            "*"
        ]
    }
],

And it also shows up in the UI:
Screenshot 2024-04-24 at 11 21 33 AM

It will also occur if a user edits the translated privileges in the UI. When the privilege is updated, it will retain the original wildcard as well as a new 'kibana':'all'.

We may want to intercept this on save/update and have a special case for when a role already contains the wild card so it is either retained (if assigning all) or overwritten (if changed), and potentially display a message to the user when a role contains the superuser style wildcard.

cc: @legrego any thoughts?

@legrego
Copy link
Member

legrego commented Apr 24, 2024

If I create a role via ES API with wildcard application privileges (like superuser and system_indices_superuser both have), and then load and save the role in the UI (making no changes), the role ends up with an additional entry that correlates to the translated 'all' privilege.

Great find, @jeramysoucy. Thanks for your attention to detail here.

We may want to intercept this on save/update and have a special case for when a role already contains the wild card so it is either retained (if assigning all) or overwritten (if changed), and potentially display a message to the user when a role contains the superuser style wildcard.

cc: @legrego any thoughts?

I'm not opposed to exploring some sort of interception if it's not an unreasonable amount of effort, and not too hacky. Otherwise, we should consider alternate approaches.

@elena-shostak
Copy link
Contributor Author

@legrego @jeramysoucy privilege with "application": "kibana-.kibana" is a subset of "application": "*" in that case.
I think rules for overwriting it might be quite complex, like what if we want to overwrite the rule only for kibana-.kibana, should we just drop the wildcard privilege then?

The alternative can be if we return the application privilege with strongest weight in that case? Because in the end the strongest privileges will be applied. WDYT?

"applications": [
    {
        "application": "kibana-.kibana",
        "privileges": [
            "all"
        ],
        "resources": [
            "*"
        ]
    },
    {
        "application": "*",
        "privileges": [
            "*"
        ],
        "resources": [
            "*"
        ]
    }
],

@elena-shostak
Copy link
Contributor Author

elena-shostak commented Apr 24, 2024

@jeramysoucy Thanks for bringing it in. Looked carefully at the setup, it seems that my normalization of application wildcard privilege on the server brought more problems than it eventually solved.

Discussed it with @legrego, we've decided to not normalize it to all, but rather display as * and disallow edit of such privileges in the UI. See attached screenshot below.

[Screenshot] Kibana wildcard role display Screenshot 2024-04-24 at 15 54 53

@jeramysoucy
Copy link
Contributor

jeramysoucy commented Apr 24, 2024

Discussed it with @legrego, we've decided to not normalize it to all, but rather display as * and disallow edit of such privileges in the UI. See attached screenshot below.

@elena-shostak Sounds good. Do we want to disallow the delete action as well?

@elena-shostak
Copy link
Contributor Author

elena-shostak commented Apr 24, 2024

@elena-shostak Sounds good. Do we want to disallow the delete action as well?

I think we can, to make it consistent with superuser role display.

Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

Sorry in advance. I found a couple of things.

  • Can we notify the user somehow that a base wildcard privilege is special? The action icons are removed, but there is nothing else to let the user know what's going on. Maybe an icon tip where the action icons usually are? cc: @legrego do we need to check with the design team or doc team for approach/wording?
  • If I view a role with the base wildcard and click Update, there is an error:
    Screenshot 2024-04-25 at 1 49 43 PM
    This is tricky, because if we disable the update button then no changes can be made to ES privileges for the role. So I think we have to trap the Kibana base wildcard on update, and only apply any ES changes.
  • If I view a role with the base wildcard, I still have options to add a Kibana privilege and view a privilege summary.
    Screenshot 2024-04-25 at 2 02 54 PM
    The summary shows all "none" (expected since this is a special case), but maybe we should remove the ability to view this is the base wildcard is the only privilege?
    Screenshot 2024-04-25 at 2 03 03 PM
    I think both of these options, Add Kibana privilege and View privilege summary, should be removed for roles with the base wildcard.

@legrego
Copy link
Member

legrego commented Apr 25, 2024

Can we notify the user somehow that a base wildcard privilege is special? The action icons are removed, but there is nothing else to let the user know what's going on. Maybe an icon tip where the action icons usually are? cc: @legrego do we need to check with the design team or doc team for approach/wording?

I'm torn on this. On one hand, it makes sense to give knowledgeable administrators this information, but this could lead to more confusion for the majority of our administrators. To my knowledge, Kibana is the primary consumer of application privileges. There might be an enterprise search use case, but they have their own bespoke authorization model that's never been compatible with our role management UI/API. Telling them this grants access to additional application privileges in effect doesn't say much, because it's really just Kibana in practice.

If I view a role with the base wildcard and click Update, there is an error.
This is tricky, because if we disable the update button then no changes can be made to ES privileges for the role. So I think we have to trap the Kibana base wildcard on update, and only apply any ES changes.

I wonder if adding API support for other application privileges would be a helpful prerequisite? #21503

I think both of these options, Add Kibana privilege and View privilege summary, should be removed for roles with the base wildcard.

++

@elena-shostak
Copy link
Contributor Author

elena-shostak commented Apr 25, 2024

@jeramysoucy @legrego

Changes addressed:

  • Made the role non editable if there is a base privilege with the wildcard present.
  • Added tests to cover scenarios with edit/delete icon actions
  • Added tests to cover scenarios with View privilege summary, Add Kibana privilege actions

See screenshot
Screenshot 2024-04-25 at 19 07 21

Let me know if that works and makes sense.

Copy link
Contributor

@jeramysoucy jeramysoucy left a comment

Choose a reason for hiding this comment

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

I just had one suggestion in the new test, to check for a read-only button render. I am approving now so that i don't hold up this PR any further.

I think making roles with the app wildcard privilege read-only in the UI is fine. These roles could only have been create/updated via the ES API anyway. I'm not sure how I feel about there not being any message to clarify this to the end user, but this is something we can come back to if needed.

Great work, Elena!

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

elena-shostak added a commit that referenced this pull request Apr 30, 2024
…181165)

## Summary

Added endpoint `GET kbn:/internal/security/roles/{space-id}` to get all
roles for provided space id.

**Note**: changes needed for application `*` privileges were
cherry-picked [to a separate
PR].(#181400)

## Example
Request  `GET kbn:/internal/security/roles/space-b`

Response
```
[
  {
    "name": "role-a",
    "metadata": {},
    "transient_metadata": {
      "enabled": true
    },
    "elasticsearch": {
      "cluster": [
        "all"
      ],
      "indices": [],
      "run_as": []
    },
    "kibana": [
      {
        "base": [],
        "feature": {
          "dev_tools": [
            "all"
          ]
        },
        "spaces": [
          "default",
          "space-b"
        ]
      }
    ],
    "_transform_error": [],
    "_unrecognized_applications": []
  },
 {
    "name": "superuser",
    "metadata": {
      "_reserved": true
    },
    "transient_metadata": {},
    "elasticsearch": {
      "cluster": [
        "all"
      ],
      "indices": [
        {
          "names": [
            "*"
          ],
          "privileges": [
            "all"
          ],
          "allow_restricted_indices": false
        },
        {
          "names": [
            "*"
          ],
          "privileges": [
            "monitor",
            "read",
            "view_index_metadata",
            "read_cross_cluster"
          ],
          "allow_restricted_indices": true
        }
      ],
      "remote_indices": [
        {
          "names": [
            "*"
          ],
          "privileges": [
            "all"
          ],
          "allow_restricted_indices": false,
          "clusters": [
            "*"
          ]
        },
        {
          "names": [
            "*"
          ],
          "privileges": [
            "monitor",
            "read",
            "view_index_metadata",
            "read_cross_cluster"
          ],
          "allow_restricted_indices": true,
          "clusters": [
            "*"
          ]
        }
      ],
      "run_as": [
        "*"
      ]
    },
    "kibana": [
      {
        "base": [
          "all"
        ],
        "feature": {},
        "spaces": [
          "*"
        ]
      }
    ],
    "_transform_error": [],
    "_unrecognized_applications": [
      "*"
    ]
  }
]
```


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Fixes: https://github.com/elastic/kibana/issues/180718__

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

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 574.6KB 574.9KB +327.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
security 67.6KB 67.8KB +174.0B
Unknown metric groups

API count

id before after diff
security 404 406 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@elena-shostak elena-shostak merged commit 4023f92 into elastic:main Apr 30, 2024
19 checks passed
@kibanamachine kibanamachine added v8.15.0 backport:skip This commit does not require backporting labels Apr 30, 2024
yuliacech pushed a commit to yuliacech/kibana that referenced this pull request May 3, 2024
…lastic#181165)

## Summary

Added endpoint `GET kbn:/internal/security/roles/{space-id}` to get all
roles for provided space id.

**Note**: changes needed for application `*` privileges were
cherry-picked [to a separate
PR].(elastic#181400)

## Example
Request  `GET kbn:/internal/security/roles/space-b`

Response
```
[
  {
    "name": "role-a",
    "metadata": {},
    "transient_metadata": {
      "enabled": true
    },
    "elasticsearch": {
      "cluster": [
        "all"
      ],
      "indices": [],
      "run_as": []
    },
    "kibana": [
      {
        "base": [],
        "feature": {
          "dev_tools": [
            "all"
          ]
        },
        "spaces": [
          "default",
          "space-b"
        ]
      }
    ],
    "_transform_error": [],
    "_unrecognized_applications": []
  },
 {
    "name": "superuser",
    "metadata": {
      "_reserved": true
    },
    "transient_metadata": {},
    "elasticsearch": {
      "cluster": [
        "all"
      ],
      "indices": [
        {
          "names": [
            "*"
          ],
          "privileges": [
            "all"
          ],
          "allow_restricted_indices": false
        },
        {
          "names": [
            "*"
          ],
          "privileges": [
            "monitor",
            "read",
            "view_index_metadata",
            "read_cross_cluster"
          ],
          "allow_restricted_indices": true
        }
      ],
      "remote_indices": [
        {
          "names": [
            "*"
          ],
          "privileges": [
            "all"
          ],
          "allow_restricted_indices": false,
          "clusters": [
            "*"
          ]
        },
        {
          "names": [
            "*"
          ],
          "privileges": [
            "monitor",
            "read",
            "view_index_metadata",
            "read_cross_cluster"
          ],
          "allow_restricted_indices": true,
          "clusters": [
            "*"
          ]
        }
      ],
      "run_as": [
        "*"
      ]
    },
    "kibana": [
      {
        "base": [
          "all"
        ],
        "feature": {},
        "spaces": [
          "*"
        ]
      }
    ],
    "_transform_error": [],
    "_unrecognized_applications": [
      "*"
    ]
  }
]
```


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Fixes: https://github.com/elastic/kibana/issues/180718__

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
yuliacech pushed a commit to yuliacech/kibana that referenced this pull request May 3, 2024
…ic#181400)

## Summary

Added transformation of application wildcard `*` privilege to `all` to
correctly filter and display roles as `superuser`.

<details>
  <summary>[Screenshot] Kibana superuser role before change</summary>
 
<img width="1508" alt="Screenshot 2024-04-23 at 11 20 31"
src="https://github.com/elastic/kibana/assets/165678770/594cf27c-64a7-49cf-bf4b-c63adca76a55">

</details>

<details>
  <summary>[Screenshot] Kibana superuser role after change</summary>
<img width="1504" alt="Screenshot 2024-04-23 at 11 17 54"
src="https://github.com/elastic/kibana/assets/165678770/96dbdaa6-f5c9-4644-82ca-f88a0f6a15b3">
</details>

### Checklist

- [X] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios


### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Fixes: https://github.com/elastic/kibana/issues/106561__

## Release note
Added transformation of application wildcard `*` privilege to `all` to
correctly filter and display roles as `superuser`.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@jasonrhodes
Copy link
Member

Thank you all so much for this change, I'd been following an earlier issue that this PR closed and it was very happy news to see! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.15 candidate backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience Feature:Users/Roles/API Keys release_note:fix Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

superuser role's Kibana privileges are inaccurate
7 participants