You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/07/13 16:16:18 UTC

[GitHub] [pulsar] nodece commented on a diff in pull request #16526: [improve][authentication] Improve get the basic authentication config

nodece commented on code in PR #16526:
URL: https://github.com/apache/pulsar/pull/16526#discussion_r920269032


##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationProviderBasic.java:
##########
@@ -48,14 +51,28 @@ public void close() throws IOException {
 
     @Override
     public void initialize(ServiceConfiguration config) throws IOException {
-        File confFile = new File(System.getProperty(CONF_SYSTEM_PROPERTY_KEY));
-        if (!confFile.exists()) {
-            throw new IOException("The password auth conf file does not exist");
-        } else if (!confFile.isFile()) {
-            throw new IOException("The path is not a file");
+        String data = config.getProperties().getProperty(CONF_PULSAR_PROPERTY_KEY);
+        if (StringUtils.isEmpty(data)) {
+            data = System.getProperty(CONF_SYSTEM_PROPERTY_KEY);
+        }
+        if (StringUtils.isEmpty(data)) {
+            throw new IOException("No basic authentication config provided");
+        }
+
+        @Cleanup BufferedReader reader = null;
+        if (org.apache.commons.codec.binary.Base64.isBase64(data)) {
+            reader = new BufferedReader(new StringReader(new String(Base64.getDecoder().decode(data),
+                    StandardCharsets.UTF_8)));
+        } else {

Review Comment:
   I think we can add a prefix so like:
   ```
   basicAuthConf=data:;base64,YOUR-BASE64
   basicAuthConf=file:///my/basic.conf
   ``



-- 
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: commits-unsubscribe@pulsar.apache.org

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