You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2019/05/28 16:18:16 UTC

[GitHub] [hive] odraese commented on a change in pull request #648: HIVE-21783: Accept Hive connections from the same domain without authentication.

odraese commented on a change in pull request #648: HIVE-21783: Accept Hive connections from the same domain without authentication.
URL: https://github.com/apache/hive/pull/648#discussion_r288188546
 
 

 ##########
 File path: service/src/java/org/apache/hive/service/auth/PlainSaslHelper.java
 ##########
 @@ -75,6 +89,70 @@ private PlainSaslHelper() {
     throw new UnsupportedOperationException("Can't initialize class");
   }
 
+  public static final class DualSaslTransportFactory extends TTransportFactory {
+    TTransportFactory otherFactory;
+    TTransportFactory noAuthFactory;
+    String hiveHost;
+
+    public DualSaslTransportFactory(TTransportFactory otherFactory, String hiveHost)
+            throws LoginException {
+      this.noAuthFactory = getPlainTransportFactory(AuthMethods.NONE.toString());
+      this.otherFactory = otherFactory;
+      this.hiveHost = hiveHost;
+    }
+
+    // Return true if the IP address is from the same domain as the server.
+    private boolean isSameDomainConnection(InetAddress remoteInetAddress) {
+      String[] hiveHostSplit = null;
+      if (hiveHost != null) {
+        hiveHostSplit = hiveHost.split("\\.");
+      }
+
+      String clientHostName = remoteInetAddress.getCanonicalHostName();
+      String[] clientHostSplit = null;
+      if (clientHostName != null) {
+        clientHostSplit = clientHostName.split("\\.");
+      }
+
+      // TODO: the callers should also pass the server address or obtain in by using some other
+      //  method. Then check whether the connection's remote address is from the same domain as
+      //  the server. For now, for the sake of testing, return true. We need to understand what
+      //  exactly it means to have connection from the same domain.
+      // For now, two hosts are in the same domain if the last two parts in their hostname are same.
+      if (hiveHostSplit.length >= 2 && clientHostSplit.length >= 2) {
 
 Review comment:
   We should check all parts of the hiveHostSplit. So, if hiveHostSplit (provided via config) is something like x.example.com, we should ensure that (only) everything below x.example.com (i.e. das.x.example.com) qualifies instead of checking just the top two levels (which are probably always cloudera and com at the final DWX deployment).

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org