-
Notifications
You must be signed in to change notification settings - Fork 0
Add tenancy access info to serialized user in threadcontext #63
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
|
||
String requestedTenant = context.getUser().getRequestedTenant(); | ||
joiner.add(requestedTenant); | ||
String tenantAccessToCheck = getTenancyAccess(requestedTenant, this.tenantPrivileges.get().tenantMap(context)); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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:
- if (hasTenantPrivilege(ActionType.WRITE)) return "WRITE"
- else if (hasTenantPrivilege(ActionType.READ)) return "READ"
- else return "NONE"
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
Signed-off-by: Craig Perkins <[email protected]>
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
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.