-
Notifications
You must be signed in to change notification settings - Fork 75
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
[Feature/extensions] Remove CommonUtils ThreadContext User from AD user checks #617
[Feature/extensions] Remove CommonUtils ThreadContext User from AD user checks #617
Conversation
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Submitted for review. Can't get tests to run due to 403 on snapshot repo. I believe the below test should fail and will comment it out if so. anomaly-detection/src/test/java/org/opensearch/ad/transport/handler/ADSearchHandlerTests.java Lines 85 to 92 in 4baf75c
|
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
@owaiskazi19 @saratvemulapalli This is ready for review. Summary of commits:
|
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.
Thanks @dbwiddis for the changes.
Also thanks for putting in placeholders.
@peternied could you take a look as well.
src/main/java/org/opensearch/ad/transport/AnomalyDetectorJobTransportAction.java
Show resolved
Hide resolved
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.
In places where the User is retrieved from the thread context, a null user is used, as the original designers of this plugin determined that null = super user. This will not be the path going forward but it is at least very convenient for us now.
I would rather those checks for a null user became checks for UserIdentity.Admin
that was returned from getUser when security was disabled.
This makes the more dangerous kind of actions much clearer in appearance as oppose to 'input validation' where we are checking for nulls.
if (getUser() == UserIdentity.Admin) {
// DO EVERYTHING!
...
}
How does this align to what you were thinking?
I completely agree with this preference and a future direction, but:
But I hope my snarky comments in the |
Another thought, there should actually be no need under a new RBAC model for the extension to even know anything about whether the user is a superadmin or an anonymous user. All we need is the access token that will be provided from the security features being moved from the plugin. We won't know what access it gives, we'll just pass it along with our API requests and the security features will identify the access roles at that point. So for the purposes of an extension, all users are the same. |
src/main/java/org/opensearch/ad/transport/DeleteAnomalyResultsTransportAction.java
Show resolved
Hide resolved
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.
LGTM. 🚢
Signed-off-by: Daniel Widdis [email protected]
Description
This copies the
User
class over from the Common Utils into aUserIdentity
class. Other than the class rename and addition of javadocs, there are no changes to the class. This is done primarily to remove the external dependency but also preserve the intention (user and roles) as a placeholder until a replacement security authentication mechanism is implemented, and retains existing functionality.In places where the User is retrieved from the thread context, a null user is used, as the original designers of this plugin determined that null = super user. This will not be the path going forward but it is at least very convenient for us now.
Final changes were made to tests to recognize the lack of failed access, and coverage which is reduced by never executing code to respond to failures.
Issues Resolved
Fixes opensearch-project/opensearch-sdk-java#23
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.