xiangfu0 commented on code in PR #20121:
URL: https://github.com/apache/pinot/pull/20121#discussion_r4441179149


##########
pinot-connectors/pinot-flink-connector/src/main/java/org/apache/pinot/connector/flink/sink/PinotSink.java:
##########
@@ -137,6 +140,21 @@ static TableConfig prepareTableConfigForSink(TableConfig 
tableConfig, String con
     return tableConfig;
   }
 
+  /// Builds an [AuthProvider] from the `authToken` in the table's batch 
config, or returns null if none is set.
+  @Nullable
+  static AuthProvider createAuthProvider(TableConfig tableConfig) {
+    IngestionConfig ingestionConfig = tableConfig.getIngestionConfig();
+    if (ingestionConfig == null || ingestionConfig.getBatchIngestionConfig() 
== null) {
+      return null;
+    }
+    List<Map<String, String>> batchConfigMaps = 
ingestionConfig.getBatchIngestionConfig().getBatchConfigMaps();
+    if (batchConfigMaps == null || batchConfigMaps.isEmpty()) {
+      return null;
+    }
+    String authToken = 
batchConfigMaps.get(0).get(BatchConfigProperties.AUTH_TOKEN);

Review Comment:
   (minor, security) This reads the credential from the table's 
batchConfigMaps. If users follow the PR's usage note and save it in the 
controller table config, the token sits in plaintext in ZK, and `GET 
/tables/{table}` returns it unredacted to anyone with read access. Minion's 
`authToken` handling sets the same precedent, so this isn't blocking. Still, it 
would help to document that the token should go on the in-memory `TableConfig` 
passed to `PinotSink`, or to accept it as a separate sink parameter.



##########
pinot-connectors/pinot-flink-connector/src/test/java/org/apache/pinot/connector/flink/sink/PinotSinkAuthTest.java:
##########
@@ -0,0 +1,82 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.connector.flink.sink;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.pinot.spi.auth.AuthProvider;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.config.table.ingestion.BatchIngestionConfig;
+import org.apache.pinot.spi.config.table.ingestion.IngestionConfig;
+import org.apache.pinot.spi.ingestion.batch.BatchConfigProperties;
+import org.apache.pinot.spi.utils.builder.TableConfigBuilder;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+
+
+public class PinotSinkAuthTest {

Review Comment:
   (minor, testing) These tests cover the `createAuthProvider` helper, but 
nothing checks that `PinotSinkWriter` forwards the provider to `uploadSegment` 
or that the header reaches the controller. An auth-enabled variant of 
`PinotSinkIntegrationTest` (controller via `BasicAuthTestUtils`, with and 
without `authToken`) would lock in the fix. I checked this locally: 401 without 
the token, upload succeeds with it. A blank-token case would also be cheap to 
add.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to