-
Notifications
You must be signed in to change notification settings - Fork 808
SOLR-15857: Add AWS Secret Manager support for ZK ACL credentials #1994
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
SOLR-15857: Add AWS Secret Manager support for ZK ACL credentials #1994
Conversation
...aws-secret-provider/src/test/org/apache/solr/secret/zk/AWSSecretCredentialsProviderTest.java
Outdated
Show resolved
Hide resolved
sort modules in alphabetical order
| ZK_CREDENTIALS_INJECTOR_CLASS_NAME_VM_PARAM_NAME, | ||
| AllAndReadonlyCredentialZkCredentialsInjector.class.getName()); | ||
|
|
||
| SolrZkClient zkClient = |
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.
Why so many ZK clients? Can't the one be used over and over for each create? At least most of the zk clients look to be the same. Also use try-with-resources to avoid the explicit need to close the zk clients
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.
Hi @risdenk
This is an existing (copied) code. For some reason (race condition?) you need to close and recreate ZKClient to make the nodes creation successful. You don't want to reuse it in the last block because you want to connect to ZK with 'OPEN_ACL_UNSAFE' ACLs.
Refactored the existing code and added new tests cases to void code duplication. Created a new setUpZKNodes method.
I think AbstractDigestZkACLAndCredentialsProvidersTestBase (which BTW is not abstract) needs more refactoring. Didn't want to make this PR bigger than it already is, but we should consider favoring composition over inheritance here.
HoustonPutman
left a comment
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.
Overall I think there might be issues with the various cli tools, using the modules provided by SOLR_MODULES.
| import software.amazon.awssdk.services.secretsmanager.model.SecretsManagerException; | ||
|
|
||
| public class AWSSecretManagerCredentialsInjector implements ZkCredentialsInjector { | ||
| public static final String SECRET_CREDENTIAL_PROVIDER_SECRET_NAME_VM_PARAM = |
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.
I'm not sure that these names make sense to me. They are not consistent with each other.
solr.zk.credentials.secretsolrZkCredentialssolr.zk.credentials.region
I think these work better.
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.
Actually, they are not consistent because they don't have the same functionality. Some are VM variable names (internal to Solr, so I followed the same naming convention of the existing creds/acl providers), one is an AWS variable value.
How about this new version?
public static final String AWS_SM_CREDENTIALS_SECRET_NAME_VM_PARAM = "zkAWSSecretCredentialsSecretName";
private static final String AWS_SM_CREDENTIALS_REGION_VM_PARAM = "zkAWSSecretCredentialsRegion";
private static final String AWS_SM_CREDENTIALS_SECRET_NAME_DEFAULT = "/solr/zk/credentials/dev/secret";
Followed AWS SM recommended naming convention.
Edit: slashes in variable names can cause problems. I am going with this syntax instead: solr.zk.credentials.dev.secret for secret name
|
|
||
| PATH=$JAVA_HOME/bin:$PATH $JVM $SOLR_ZK_CREDS_AND_ACLS $ZKCLI_JVM_FLAGS -Dlog4j.configurationFile=$log4j_config -Dsolr.home=$solr_home \ | ||
| -classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*:$sdir/../../lib/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} | ||
| -Dsolr.install.dir=$SOLR_DIR -Dsolr.modules=$SOLR_MODULES -classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*:$sdir/../../lib/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} |
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.
SOLR_MODULES might not be provided, so probably want to use "${SOLR_MODULES:-}"
Also $SOLR_DIR needs to be in quotes.
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.
The operator has to set SOLR_MODULES in zkcli.*
In the same way we expect it in solr.in.* to enable different modules.
We'll add the missing quotes.
|
|
||
| solr_home="$sdir/../../solr" | ||
|
|
||
| # Get solr dir with fullpath |
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.
Are the Solr Modules auto-added with the bin/solr <tool> command?
Also are you sure that ZKCLI.java and SolrCLI.java use the solr.modules option? I thought that was enabled through the solr.xml, which those tools wouldn't know about.
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.
I am curious to find out the answer!
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 @HoustonPutman for looking at this
Little background: We discussed this last year if you remember as part of a bigger PR.
The issue we faced at that time was that SolrJ doesn't "see" the libraries part of the other modules as Solr default class loader does't load classes from different modules. We decided at that time to split the contrib into small ones to make that possible.
One of those contribs (that answers your question) is this one. It enables passing a custom class loader to SolrZKClient.
To answer your question:
- It's not possible to rely on solr.xml for the reason explained here.
- ZKCli and SolrCli don't use solr.modules directly but via NodeConfig. NodeConfig reads solr.modules passed through SOLR_MODULES in zkcli.* or solr.in.*
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.
Hi Houston,
I have added solr modules to solr and solr.cmd.
PS: There is another way to load the modules without touching solr and solr.cmd but this requires changing a lot of "tool" classes where SolrZkClient instantiation is duplicated (the code is duplicated 12 times in 8 diff classes). I think we should extract the code instantiating the SolrZkClient to a separate class as well as considering merging ZK related tool classes.
@HoustonPutman
@epugh
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.
I would LOVE to see that refactoring on SolrZkClient.. I've been looking more at that code base, and I think there is a LOT of opportunity for clean up. We have a LOT of tickets that are around reducing what is in solr and solr.cmd in favour of Java code, so this is a bit of a step in the wrong direction!
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.
Hi @epugh
I have a new PR where I separated code instantiating SolrZkClient and CloudSolrClient in ZK related SolrCli tool classes.
The PR adds also a SolrClassLoader to CloudHttp2SolrClient Builder which allows to load solr modules libs without relying on solr and solr.cmd scripts.
As soon as it's approved internally will push it upstream for your review.
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.
This is exciting!
Add double quotes
HoustonPutman
left a comment
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.
ZkCli is getting replaced by SolrCLI, so SolrCLI needs support too
| public static final String AWS_SM_CREDENTIALS_SECRET_NAME_VM_PARAM = | ||
| "zkAWSSecretCredentialsSecretName"; | ||
| private static final String AWS_SM_CREDENTIALS_REGION_VM_PARAM = "zkAWSSecretCredentialsRegion"; | ||
| private static final String AWS_SM_CREDENTIALS_SECRET_NAME_DEFAULT = | ||
| "solr.zk.credentials.dev.secret"; |
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.
zkAWSSecretCredentialsSecretName->zkCredentialsAWSSecretNamezkAWSSecretCredentialsRegion->zkCredentialsAWSRegionsolr.zk.credentials.dev.secret->solr.zk.credentials.secret
|
|
||
| PATH=$JAVA_HOME/bin:$PATH $JVM $SOLR_ZK_CREDS_AND_ACLS $ZKCLI_JVM_FLAGS -Dlog4j.configurationFile=$log4j_config -Dsolr.home=$solr_home \ | ||
| -classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*:$sdir/../../lib/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} | ||
| -Dsolr.install.dir="$SOLR_DIR" -Dsolr.modules="$SOLR_MODULES" -classpath "$sdir/../../solr-webapp/webapp/WEB-INF/lib/*:$sdir/../../lib/ext/*:$sdir/../../lib/*" org.apache.solr.cloud.ZkCLI ${1+"$@"} |
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.
"$SOLR_MODULES" -> "${SOLR_MODULES:-}"
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.
Hi @HoustonPutman ,
I have added the changes.
As soon as you're about to approve the PR will update the ref. guide.
|
This PR had no visible activity in the past 60 days, labeling it as stale. Any new activity will remove the stale label. To attract more reviewers, please tag someone or notify the dev@solr.apache.org mailing list. Thank you for your contribution! |
…pport_to_store_ZK_credentials
epugh
left a comment
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.
It looks like you've added the additional support to both the zkcli and the solr scripts, which is great. There is another PR, #2298 that I hope to merge in the next few days which establishes parity between solr zk subommands and what zkcli, and I hope to remove zkcli from the main branch. If that happened, would it make sense/help you to have this support be ONLY available for the solr zk commands?
| ``` | ||
|
|
||
|
|
||
| - Pass the secret name and region trough `solr.in.sh:` |
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.
"through"?
|
|
||
| solr_home="$sdir/../../solr" | ||
|
|
||
| # Get solr dir with fullpath |
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.
I would LOVE to see that refactoring on SolrZkClient.. I've been looking more at that code base, and I think there is a LOT of opportunity for clean up. We have a LOT of tickets that are around reducing what is in solr and solr.cmd in favour of Java code, so this is a bit of a step in the wrong direction!
|
Are we sure this fits as a Solr module? Since this is client-side solrj code, it could be in e.g. |
Actually, this is a server side code. Now, from SolrJ side we have 3 options:
Somewhere down the line SolrZkClient will instantiate an AWSSecretManagerCredentialsInjector. |
|
This PR had no visible activity in the past 60 days, labeling it as stale. Any new activity will remove the stale label. To attract more reviewers, please tag someone or notify the dev@solr.apache.org mailing list. Thank you for your contribution! |
|
I don't know that it changes anything, but at this point the zkcli.bat and zkcli.sh are no longer part of solr! Does that help at all? Also, it sounds like we had a refactoring that you were hoping to push up, did that ever make it fruition? |
|
This PR has had no activity for 60 days and is now labeled as stale. Any new activity will remove the stale label. To attract more reviewers, please tag people who might be familiar with the code area and/or notify the dev@solr.apache.org mailing list. To exempt this PR from being marked as stale, make it a draft PR or add the label "exempt-stale". If left unattended, this PR will be closed after another 60 days of inactivity. Thank you for your contribution! |
|
This PR is now closed due to 60 days of inactivity after being marked as stale. Re-opening this PR is still possible, in which case it will be marked as active again. |
https://issues.apache.org/jira/browse/SOLR-17020
Description
Solr currently connects to Zookeeper and manages ACLs using a set of credentials (when using Digest scheme). These credentials are either passed via the command line (system properties) or fetched from an unencrypted file on every host in the cluster. Clearly, this approach lacks sufficient security.
The proposed change of this contribution intends to integrate AWS Secret Manager for credential storage, offering two primary advantages:
• Improved security measures.
• Streamlined operations by centralizing credential storage, eliminating the need to update multiple hosts/files whenever passwords are changed.
Solution
This is a new module to support storing Zookeeper credentials in an AWS Secret Manager.
Added a new implementation of ZkCredentialsInjector that pulls the creds from AWS SM.
Ref guide in progress...
Tests
Added test cases.
Integration tests also made in AWS environment.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.