You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/05/12 01:07:57 UTC

[GitHub] [pinot] apucher commented on a diff in pull request #8670: Add pluggable client auth provider

apucher commented on code in PR #8670:
URL: https://github.com/apache/pinot/pull/8670#discussion_r870862828


##########
pinot-spi/src/main/java/org/apache/pinot/spi/ingestion/batch/spec/SegmentGenerationJobSpec.java:
##########
@@ -124,6 +124,12 @@ public class SegmentGenerationJobSpec implements Serializable {
 
   /**
    * Controller auth token
+   *
+   * <br/>NOTE: jobs MUST NOT allow references to external tokens via URL or path to prevent:
+   * (a) file system crawling
+   * (b) unauthorized injection of system tokens from the server's local file system.
+   *
+   * Instead, resolve tokens right when the job command is run. This allows injection of client-local credentials.
    */
   private String _authToken;

Review Comment:
   the job spec is a serializable object. any tokens should be resolved prior to submitting and storing it.
   
   (also, token retrieval with a user-controlled URL is famous for creating all kinds of data protection issues)



##########
pinot-common/src/main/java/org/apache/pinot/common/auth/StaticTokenAuthProvider.java:
##########
@@ -0,0 +1,68 @@
+/**
+ * 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.common.auth;
+
+import java.util.Collections;
+import java.util.Map;
+import javax.ws.rs.core.HttpHeaders;
+import org.apache.pinot.spi.auth.AuthProvider;
+
+
+/**
+ * Auth provider for static client tokens, typically used for job specs or when mimicking legacy behavior.
+ */
+public class StaticTokenAuthProvider implements AuthProvider {
+  public static final String HEADER = "header";
+  public static final String PREFIX = "prefix";
+  public static final String TOKEN = "token";
+
+  protected final String _header;
+  protected final String _prefix;
+  protected final String _token;
+
+  public StaticTokenAuthProvider(String token) {
+    _header = HttpHeaders.AUTHORIZATION;
+    _prefix = "";
+    _token = token;
+  }
+
+  public StaticTokenAuthProvider(AuthConfig authConfig) {
+    _header = AuthProviderUtils.getOrDefault(authConfig, HEADER, HttpHeaders.AUTHORIZATION);
+    _prefix = AuthProviderUtils.getOrDefault(authConfig, PREFIX, "Basic");
+    _token = authConfig.getProperties().get(TOKEN).toString();
+  }
+
+  @Override
+  public Map<String, Object> getRequestHeaders() {
+    return Collections.singletonMap(_header, makeToken());

Review Comment:
   done



-- 
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@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org