hive-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (Jira)" <j...@apache.org>
Subject [jira] [Work logged] (HIVE-24059) Llap external client - Initial changes for running in cloud environment
Date Mon, 31 Aug 2020 20:15:00 GMT

     [ https://issues.apache.org/jira/browse/HIVE-24059?focusedWorklogId=476799&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-476799
]

ASF GitHub Bot logged work on HIVE-24059:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 31/Aug/20 20:14
            Start Date: 31/Aug/20 20:14
    Worklog Time Spent: 10m 
      Work Description: prasanthj commented on a change in pull request #1418:
URL: https://github.com/apache/hive/pull/1418#discussion_r480371903



##########
File path: llap-common/src/java/org/apache/hadoop/hive/llap/security/DefaultJwtSharedSecretProvider.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.hadoop.hive.llap.security;
+
+import com.google.common.base.Preconditions;
+import io.jsonwebtoken.security.Keys;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.StandardCharsets;
+import java.security.Key;
+
+import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.LLAP_EXTERNAL_CLIENT_CLOUD_DEPLOYMENT_SETUP_ENABLED;
+import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET;
+
+/**
+ * Default implementation of {@link JwtSecretProvider}.
+ *
+ * 1. It first tries to get shared secret from conf {@link HiveConf.ConfVars#LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET}
+ * using {@link Configuration#getPassword(String)}.
+ *
+ * 2. If not found, it tries to read from env var {@link #LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR}.
+ *
+ * If secret is not found even after 1) and 2), {@link #init(Configuration)} methods throws
{@link NullPointerException}.
+ *
+ * It uses the same encryption and decryption secret which can be used to sign and verify
JWT.
+ */
+public class DefaultJwtSharedSecretProvider implements JwtSecretProvider {
+
+  public static final String LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR =
+      "LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR";
+
+  private Key jwtEncryptionKey;
+
+  @Override public Key getEncryptionSecret() {
+    return jwtEncryptionKey;
+  }
+
+  @Override public Key getDecryptionSecret() {
+    return jwtEncryptionKey;
+  }
+
+  @Override public void init(final Configuration conf) {
+    char[] sharedSecret;
+    byte[] sharedSecretBytes = null;
+
+    // try getting secret from conf first
+    // if not found, get from env var - LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR
+    try {
+      sharedSecret = conf.getPassword(LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET.varname);
+    } catch (IOException e) {
+      throw new RuntimeException("Unable to get password [hive.llap.external.client.cloud.jwt.shared.secret]
- "
+          + e.getMessage(), e);
+    }
+    if (sharedSecret != null) {
+      ByteBuffer bb = StandardCharsets.UTF_8.encode(CharBuffer.wrap(sharedSecret));
+      sharedSecretBytes = new byte[bb.remaining()];
+      bb.get(sharedSecretBytes);
+    } else {
+      String sharedSecredFromEnv = System.getenv(LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR);
+      if (sharedSecredFromEnv != null) {
+        sharedSecretBytes = sharedSecredFromEnv.getBytes();
+      }
+    }
+
+    Preconditions.checkNotNull(sharedSecretBytes,

Review comment:
       nit: IllegalStateException is more appropriate I guess. check state instead? 

##########
File path: llap-common/src/java/org/apache/hadoop/hive/llap/security/DefaultJwtSharedSecretProvider.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.hadoop.hive.llap.security;
+
+import com.google.common.base.Preconditions;
+import io.jsonwebtoken.security.Keys;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.conf.HiveConf;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.StandardCharsets;
+import java.security.Key;
+
+import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.LLAP_EXTERNAL_CLIENT_CLOUD_DEPLOYMENT_SETUP_ENABLED;
+import static org.apache.hadoop.hive.conf.HiveConf.ConfVars.LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET;
+
+/**
+ * Default implementation of {@link JwtSecretProvider}.
+ *
+ * 1. It first tries to get shared secret from conf {@link HiveConf.ConfVars#LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET}
+ * using {@link Configuration#getPassword(String)}.
+ *
+ * 2. If not found, it tries to read from env var {@link #LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR}.
+ *
+ * If secret is not found even after 1) and 2), {@link #init(Configuration)} methods throws
{@link NullPointerException}.
+ *
+ * It uses the same encryption and decryption secret which can be used to sign and verify
JWT.
+ */
+public class DefaultJwtSharedSecretProvider implements JwtSecretProvider {
+
+  public static final String LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR =
+      "LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR";
+
+  private Key jwtEncryptionKey;
+
+  @Override public Key getEncryptionSecret() {
+    return jwtEncryptionKey;
+  }
+
+  @Override public Key getDecryptionSecret() {
+    return jwtEncryptionKey;
+  }
+
+  @Override public void init(final Configuration conf) {
+    char[] sharedSecret;
+    byte[] sharedSecretBytes = null;
+
+    // try getting secret from conf first
+    // if not found, get from env var - LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR
+    try {
+      sharedSecret = conf.getPassword(LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET.varname);
+    } catch (IOException e) {
+      throw new RuntimeException("Unable to get password [hive.llap.external.client.cloud.jwt.shared.secret]
- "
+          + e.getMessage(), e);
+    }
+    if (sharedSecret != null) {
+      ByteBuffer bb = StandardCharsets.UTF_8.encode(CharBuffer.wrap(sharedSecret));
+      sharedSecretBytes = new byte[bb.remaining()];
+      bb.get(sharedSecretBytes);
+    } else {
+      String sharedSecredFromEnv = System.getenv(LLAP_EXTERNAL_CLIENT_CLOUD_JWT_SHARED_SECRET_ENV_VAR);
+      if (sharedSecredFromEnv != null) {

Review comment:
       also check for empty string?




----------------------------------------------------------------
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.

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 476799)
    Time Spent: 1.5h  (was: 1h 20m)

> Llap external client - Initial changes for running in cloud environment
> -----------------------------------------------------------------------
>
>                 Key: HIVE-24059
>                 URL: https://issues.apache.org/jira/browse/HIVE-24059
>             Project: Hive
>          Issue Type: Sub-task
>          Components: llap
>            Reporter: Shubham Chaurasia
>            Assignee: Shubham Chaurasia
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Please see problem description in https://issues.apache.org/jira/browse/HIVE-24058
> Initial changes include - 
> 1. Moving LLAP discovery logic from client side to server (HS2 / get_splits) side.
> 2. Opening additional RPC port in LLAP Daemon.
> 3. JWT Based authentication on this port.
> cc [~prasanth_j] [~jdere] [~anishek] [~thejas]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Mime
View raw message