-
Notifications
You must be signed in to change notification settings - Fork 280
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
[Refactor] Adopt request builder patterns for SecurityRestApiActions for consistency and clarity #3123
[Refactor] Adopt request builder patterns for SecurityRestApiActions for consistency and clarity #3123
Conversation
@peternied and @cwperks as i promised. So far all methods aka CRUD. PATCH will be added a bit later. |
14ee156
to
d838305
Compare
Codecov Report
@@ Coverage Diff @@
## main #3123 +/- ##
============================================
+ Coverage 62.51% 63.15% +0.63%
- Complexity 3403 3449 +46
============================================
Files 259 263 +4
Lines 20055 20023 -32
Branches 3370 3341 -29
============================================
+ Hits 12538 12646 +108
+ Misses 5866 5748 -118
+ Partials 1651 1629 -22
|
d838305
to
68bff72
Compare
I fixed current failures |
cd21190
to
ca43ee0
Compare
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.
Added some comments around this draft - overall a big fan of this direction.
src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java
Outdated
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.
Thank you @willyborankin ! I took a first pass at a review for this PR and left a few comments. Overall, I like the introduction of higher level abstractions and creating a common class for common Responses.
src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/dlic/rest/api/SecurityConfiguration.java
Show resolved
Hide resolved
src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java
Outdated
Show resolved
Hide resolved
0e2c1f1
to
ec30ef3
Compare
@willyborankin I got an email about a comment, but cannot see it any longer:
I like the Likewise |
@cwperks Yes I reverted the commit. found a bug. |
2fcc3ee
to
24c23c3
Compare
7b37f5c
to
584cc26
Compare
Hi, @peternied and @cwperks. I finished and address changes we discussed. Changes:
Added a common |
584cc26
to
ac93e34
Compare
src/main/java/org/opensearch/security/dlic/rest/api/AbstractApiAction.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/dlic/rest/api/RolesApiAction.java
Outdated
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.
@willyborankin This PR looks good to me. I like the change this introduces to reduce the amount of notImplemented
around the concrete APIs.
What work is remaining before marking this ready for review?
I'm going to add 1 test and open it as |
ac93e34
to
1c75d36
Compare
Signed-off-by: Andrey Pleskach <ples@aiven.io>
Signed-off-by: Andrey Pleskach <ples@aiven.io>
- extract configuration validation into separate class EndpointValidator - SecurityConfiguration is a companion class now - Renamed getConfigName -> getConfigType Signed-off-by: Andrey Pleskach <ples@aiven.io>
Signed-off-by: Andrey Pleskach <ples@aiven.io>
Signed-off-by: Andrey Pleskach <ples@aiven.io>
Signed-off-by: Andrey Pleskach <ples@aiven.io>
- Moved resourceName to EndpointValidator - Added SecurityConfigurationTest Signed-off-by: Andrey Pleskach <ples@aiven.io>
Changes: - Changed some names fir better readability - Added test for validations Signed-off-by: Andrey Pleskach <ples@aiven.io>
95f509a
to
6b86556
Compare
Signed-off-by: Andrey Pleskach <ples@aiven.io>
63ed510
to
c5cbd7e
Compare
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/security/backport-2.x
# Create a new branch
git switch --create backport/backport-3123-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0338cdd4ab701e6dfdbaaf49765300b1d6190aa0
# Push it to GitHub
git push --set-upstream origin backport/backport-3123-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security/backport-2.x Then, create a pull request where the |
…for consistency and clarity (opensearch-project#3123) Main differences are: - Using functional approach to handle requests instead of inheritance which (IMHO) simplify code support and reading - All checks and verification stay the same, I only changed names. - PATCH uses the same validation rules as PUT and DELETE methods Signed-off-by: Andrey Pleskach <ples@aiven.io> (cherry picked from commit 0338cdd)
) The resent refactoring of the REST APIs: #3123 introduce a regression in how roles-mapping verification has worked before. The old solution verified only hidden roles both for internal users and roles mapping, while new was too strict and forbid to do it for both. This PR fixes the problem and uses the same logic as it was before. - In case of roles-mapping it verifies only a role associated with it that the role is not hidden. - In case of internal users it verifies that a role is not hidden and roles-mapping associated with the role is mutable So verification was split and added to the corresponding ActionApi class which is more convenient as it was before. Signed-off-by: Andrey Pleskach <ples@aiven.io>
) The resent refactoring of the REST APIs: #3123 introduce a regression in how roles-mapping verification has worked before. The old solution verified only hidden roles both for internal users and roles mapping, while new was too strict and forbid to do it for both. This PR fixes the problem and uses the same logic as it was before. - In case of roles-mapping it verifies only a role associated with it that the role is not hidden. - In case of internal users it verifies that a role is not hidden and roles-mapping associated with the role is mutable So verification was split and added to the corresponding ActionApi class which is more convenient as it was before. Signed-off-by: Andrey Pleskach <ples@aiven.io> (cherry picked from commit 53f64b9) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
REST API clean up continuation.
Main differences are:
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.