-
Notifications
You must be signed in to change notification settings - Fork 275
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
Auto-convert V6 configuration instances into V7 configuration instances (for OpenSearch 2.x only) #4753
Conversation
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
59758a7
to
51dbfb5
Compare
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
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 @nibix! Left a few comments. This change looks good to me. This will greatly simplify the security codebase to only have to keep track of the v7 models.
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 <[email protected]>
Signed-off-by: Nils Bandener <[email protected]>
@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. |
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:
ConfigurationRepository
which 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.DynamicConfigFactory
which consumesSecurityDynamicConfiguration<>
instances and createsConfigModel
andDynamicConfigModel
instances. If it finds V6 classes inSecurityDynamicConfiguration<>
, it createsConfigModelV6
instances, if it finds V7 classes, it createsConfigModelV7
instances.ConfigModelV6
andConfigModelV7
classes contain business logic which evaluates roles and permissions.PrivilegesEvaluator
.This PR changes the architecture at level 2:
ConfigurationRepository
is 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.DynamicConfigFactory
does no longer need a distinction between two config versions.ConfigModelV6
becomes redundant.PrivilegeEvaluator
consumes 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
LegacyConfigV6AutoConversionTest
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.