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] Support read-only remote index & cluster sections with read_security access #183126

Merged
merged 11 commits into from
May 16, 2024

Conversation

elena-shostak
Copy link
Contributor

@elena-shostak elena-shostak commented May 10, 2024

Summary

Changed privilege check from manage_security to read_security, so user with read_security can view remote indexes/remote clusters sections for role.

[Screenshot BEFORE] Role for viewer user with read security before change Screenshot 2024-05-07 at 17 30 22
[Screenshot AFTER] Role for viewer user with read security after change Screenshot 2024-05-07 at 17 29 30

Checklist

For maintainers

Fixes: #182847

Release note

Changed privilege check from manage_security to read_security, so user with read_security can view remote indexes/remote clusters sections for role.

@elena-shostak elena-shostak added bug Fixes for quality problems that affect the customer experience 8.15 candidate Feature:Users/Roles/API Keys Team:Security Team focused on: Auth, Users, Roles, Spaces, Audit Logging, and more! labels May 10, 2024
@@ -49,7 +49,7 @@ export function defineRoleMappingFeatureCheckRoute({ router, logger }: RouteDefi
const esClient = (await context.core).elasticsearch.client;
const { has_all_requested: canManageRoleMappings } =
await esClient.asCurrentUser.security.hasPrivileges({
body: { cluster: ['manage_security'] },
body: { cluster: ['read_security'] },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Long term, would it make more sense to change this internal endpoint to '/internal/security/_check_security_features'? In that case we would rename 'canManageRoleMappings' to 'canReadSecurity'. We're really using this (all use cases that I can find) to check which features are enabled, with a minimum requirement of "security_read" priv.

Do we know if we have any external (non-Kibana) callers to this API? If not, is it ok to move/change the API now?

cc: @legrego @azasypkin

Copy link
Member

Choose a reason for hiding this comment

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

Long term, would it make more sense to change this internal endpoint to '/internal/security/_check_security_features'? In that case we would rename 'canManageRoleMappings' to 'canReadSecurity'. We're really using this (all use cases that I can find) to check which features are enabled, with a minimum requirement of "security_read" priv.

++ we shouldn't be calling a Role Mappings internal API from the Role Management screen. This isn't a new problem though, it exists in main since the introduction of remote index privileges. I'll leave the "when" up to y'all: I don't have a strong preference if we refactor in this PR, or create a follow-up issue to address as time permits.

Do we know if we have any external (non-Kibana) callers to this API? If not, is it ok to move/change the API now?

We shouldn't have external callers to this API. We reserve the right to change /internal APIs as needed. If we are aware that an /internal API has become defacto public, then it changes the equation a bit, but I think we are safe in this instance.

@elena-shostak elena-shostak added release_note:fix backport:skip This commit does not require backporting labels May 10, 2024
@elena-shostak
Copy link
Contributor Author

/ci

@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@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 May 13, 2024 10:41
@elena-shostak elena-shostak requested a review from a team as a code owner May 13, 2024 10:41
@elasticmachine
Copy link
Contributor

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

@jeramysoucy jeramysoucy self-requested a review May 13, 2024 13:41
@elena-shostak
Copy link
Contributor Author

@elasticmachine merge upstream

@elena-shostak
Copy link
Contributor Author

elena-shostak commented May 16, 2024

@jeramysoucy

As agreed, pushed changes, ready for review:

  • Moved /internal/security/_check_role_mapping_features to /internal/security/_check_security_features.
  • Created corresponding API Client SecurityFeaturesAPIClient and moved feature check there. It is now used in RoleMappingsGridPage, EditRoleMappingPage, useFeatureCheck hook for EditRolePage has been updated accordingly.
  • All tests adjusted accordingly.

cc @legrego @azasypkin

@jeramysoucy jeramysoucy changed the title [Roles] Role mappings with read_security access [Roles] Support read-only remote index & cluster sections with read_security access May 16, 2024
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.

LGTM! Just had a few nits and a question.

Thanks for implementing the API refactor! Can we add a note in the PR description that we moved the internal API?

@@ -74,6 +75,7 @@ export function defineRoutes(params: RouteDefinitionParams) {
defineDeprecationsRoutes(params); // deprecated kibana user roles are not applicable, these HTTP APIs are not needed
defineIndicesRoutes(params); // the ES privileges form used to help define roles (only consumer) is disabled, so there is no need for these HTTP APIs
defineRoleMappingRoutes(params); // role mappings are managed internally, based on configurations in control plane, these HTTP APIs are not needed
defineSecurityFeatureRoutes(params);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is still ok not to register this endpoint in serverless. But as it is now no longer a role mappings endpoint (never really was), would it benefit us to register it for serverless? Would it simplify the code we had to add to work around needing a "conditional hook" if we could just call the endpoint regardless of build flavor and rely on the response?

cc: @legrego @SiddharthMantri

Copy link
Member

Choose a reason for hiding this comment

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

I think it is still ok not to register this endpoint in serverless.

I agree, it shouldn't be necessary for serverless.

But as it is now no longer a role mappings endpoint (never really was), would it benefit us to register it for serverless? Would it simplify the code we had to add to work around needing a "conditional hook" if we could just call the endpoint regardless of build flavor and rely on the response?

I'll defer to y'all on the complexity tradeoffs. One thing I'm not sure about is if the ES APIs we call in here are all available on Serverless, or if the payloads differ between serverless and stateful. If we enable this endpoint for serverless, then we'll need to validate that it continues to function correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would keep it out of serverless TBH, at least in scope of that PR since it doesn't change access to the endpoint.
Making endpoint available in serverless changes the scope of this PR a lot then.
Though I'm not sure how much we would leverage with this change, it might require a carefull testing for integration/usage of it and not be that trivial in the end. Seems like the benefit of it might be negligible.

If we consider such change, it would be better to do that in a separate issue/PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would keep it out of serverless TBH, at least in scope of that PR since it doesn't change access to the endpoint.
...
If we consider such change, it would be better to do that in a separate issue/PR.

Sounds good to me. Yeah, I don't think we need to hold up this PR at all. I just wanted to have the discussion.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
security 515 517 +2

Async chunks

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

id before after diff
security 582.0KB 582.4KB +432.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 68.9KB 69.1KB +121.0B
Unknown metric groups

async chunk count

id before after diff
security 21 22 +1

History

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

@elena-shostak elena-shostak merged commit 3c908b2 into elastic:main May 16, 2024
20 checks passed
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.

User with read_security should be able to see remote indexes and remote cluster privileges
6 participants