Skip to content

Conversation

@cwperks
Copy link
Owner

@cwperks cwperks commented Jul 29, 2025

Description

This PR adds information about the user's level of access to the requested tenant when serializing the user into the threadcontext. There can be 1 of 3 levels of access. 1) No Access - user has no access to the requested tenant, 2) Read Only - User has read only access to the requested tenant and 3) Write access - user can save saved objects to the requested tenant

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • API changes companion pull request created
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>

String requestedTenant = context.getUser().getRequestedTenant();
joiner.add(requestedTenant);
String tenantAccessToCheck = getTenancyAccess(requestedTenant, this.tenantPrivileges.get().tenantMap(context));
Copy link

Choose a reason for hiding this comment

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

For clusters with many tenants (I recently heard about one with 2000 tenants ;-) it will be significantly more efficient to use tenantPrivileges.hasTenantPrivilege():

public boolean hasTenantPrivilege(PrivilegesEvaluationContext context, String tenant, ActionType actionType) {

tenantMap() needs to compute the privileges for all existing tenants and is therefore very slow

Copy link
Owner Author

Choose a reason for hiding this comment

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

Does that distinguish between no access, read access and write access?

Copy link

Choose a reason for hiding this comment

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

well, we need to call it potentially twice:

  1. if (hasTenantPrivilege(ActionType.WRITE)) return "WRITE"
  2. else if (hasTenantPrivilege(ActionType.READ)) return "READ"
  3. else return "NONE"

Copy link
Owner Author

Choose a reason for hiding this comment

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

got it, pushing a commit for that shortly.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Pushed a commit and opened a PR to the main repo: opensearch-project#5519

Signed-off-by: Craig Perkins <cwperx@amazon.com>
cwperks added 2 commits July 30, 2025 10:18
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants