Auto-convert V6 configuration instances into V7 configuration instances (for OpenSearch 2.x only)#4753
Merged
cwperks merged 9 commits intoopensearch-project:2.xfrom Oct 4, 2024
Conversation
1 task
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
59758a7 to
51dbfb5
Compare
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
cwperks
reviewed
Oct 2, 2024
src/main/java/org/opensearch/security/configuration/ConfigurationRepository.java
Show resolved
Hide resolved
src/integrationTest/java/org/opensearch/security/legacy/LegacyConfigV6AutoConversionTest.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/security/securityconf/impl/CType.java
Outdated
Show resolved
Hide resolved
src/integrationTest/java/org/opensearch/security/legacy/LegacyConfigV6AutoConversionTest.java
Show resolved
Hide resolved
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
Signed-off-by: Nils Bandener <nils.bandener@eliatra.com>
cwperks
approved these changes
Oct 3, 2024
Member
|
@DarshitChanpura @willyborankin @derek-ho @peternied Could we get one more review on this? This change helps pave the way forward for Optimized Privileges Evaluation as it simplifies the code greatly to only depend on one version of the models. |
willyborankin
approved these changes
Oct 4, 2024
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is secondary to #4546. Please review #4546 first.
This relates to the proposal "Behind the scenes conversion from V6 to V7" from #4493.
This converts the V6 config instances to V7 config instances "behind the scenes". This allows to save a lot of duplicate implementation regarding to privilege evaluation and possibly also further logic.
As an additional benefit, this makes it possible to use
SecurityDynamicConfiguration<>instances in a generically type-safe manner. So far, one usually needs to useSecurityDynamicConfiguration<?>instances and do unsafe casts.This only touches the runtime representation of the configuration. If there's a V6 configuration in the configuration index, it remains untouched. The possibility to update configuration in V6 format will remain.
This is only for OpenSearch 2.x. For the OpenSearch main branch, #4546 removes V6 config support alltogether.
Behind the scenes conversion
Some more detail on what is changed by this PR:
The configuration architecture consists of these levels:
ConfigurationRepositorywhich managesSecurityDynamicConfiguration<>instances which contain as entry instances oforg.opensearch.security.securityconf.impl.v6.RoleV6,org.opensearch.security.securityconf.impl.v6.RoleMappingsV6,org.opensearch.security.securityconf.impl.v7.RoleV7,org.opensearch.security.securityconf.impl.v7.RoleMappingsV7, etc.DynamicConfigFactorywhich consumesSecurityDynamicConfiguration<>instances and createsConfigModelandDynamicConfigModelinstances. If it finds V6 classes inSecurityDynamicConfiguration<>, it createsConfigModelV6instances, if it finds V7 classes, it createsConfigModelV7instances.ConfigModelV6andConfigModelV7classes contain business logic which evaluates roles and permissions.PrivilegesEvaluator.This PR changes the architecture at level 2:
ConfigurationRepositoryis changed in this way: If it finds V6 instances likeorg.opensearch.security.securityconf.impl.v6.RoleV6, it auto-converts these to V7 instances likeorg.opensearch.security.securityconf.impl.v7.RoleV7. The V7 classes already have functionality for that which is already used for the securityadmin migration command.DynamicConfigFactorydoes no longer need a distinction between two config versions.ConfigModelV6becomes redundant.PrivilegeEvaluatorconsumes the super interfaceConfigModel, it does not notice anything about this change.Category: Refactoring
Why these changes are required? - Minimize duplicate logic for privilege evaluation
What is the old behavior before changes and new behavior after changes? - none
Category: Refactoring
Why these changes are required? - Minimize duplicate logic for privilege evaluation
What is the old behavior before changes and new behavior after changes? no behavior changes
Issues Resolved
Testing
LegacyConfigV6AutoConversionTestCheck 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.