You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/07/15 21:44:01 UTC

[GitHub] [solr] thelabdude commented on a change in pull request #222: SOLR-15525: Read ZK credentials from a file specified using a system property instead of exposing plain-text credentials

thelabdude commented on a change in pull request #222:
URL: https://github.com/apache/solr/pull/222#discussion_r670825201



##########
File path: solr/core/src/test/org/apache/solr/cloud/VMParamsZkACLAndCredentialsProvidersTest.java
##########
@@ -250,6 +276,33 @@ private void useReadonlyCredentials() {
     System.setProperty(VMParamsSingleSetCredentialsDigestZkCredentialsProvider.DEFAULT_DIGEST_USERNAME_VM_PARAM_NAME, "readonlyACLUsername");
     System.setProperty(VMParamsSingleSetCredentialsDigestZkCredentialsProvider.DEFAULT_DIGEST_PASSWORD_VM_PARAM_NAME, "readonlyACLPassword");
   }
+
+  private void useReadonlyCredentialsFromFile() throws IOException {
+    useCredentialsFromFile("readonlyACLUsername", "readonlyACLPassword");
+  }
+
+  private void useAllCredentialsFromFile() throws IOException {
+    useCredentialsFromFile("connectAndAllACLUsername", "connectAndAllACLPassword");
+  }
+
+  private void useCredentialsFromFile(String username, String password) throws IOException {
+    clearSecuritySystemProperties();
+
+    System.setProperty(SolrZkClient.ZK_CRED_PROVIDER_CLASS_NAME_VM_PARAM_NAME, VMParamsSingleSetCredentialsDigestZkCredentialsProvider.class.getName());
+
+    Properties props = new Properties();
+    props.setProperty(VMParamsSingleSetCredentialsDigestZkCredentialsProvider.DEFAULT_DIGEST_USERNAME_VM_PARAM_NAME, username);
+    props.setProperty(VMParamsSingleSetCredentialsDigestZkCredentialsProvider.DEFAULT_DIGEST_PASSWORD_VM_PARAM_NAME, password);
+    saveCredentialsFile(props);
+  }
+
+  private void saveCredentialsFile(Properties props) throws IOException {
+    File credentialsFile = createTempFile("zk-creds", "properties").toFile();
+    try (FileWriter writer = new FileWriter(credentialsFile, StandardCharsets.UTF_8)) {
+      props.store(writer, "test");
+    }
+    System.setProperty(VMParamsSingleSetCredentialsDigestZkCredentialsProvider.DEFAULT_DIGEST_FILE_VM_PARAM_NAME, credentialsFile.getAbsolutePath());

Review comment:
       @madrob I think you have perms to just push that change to the PR branch, no?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org