[ 
https://issues.apache.org/jira/browse/DRILL-4280?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15625922#comment-15625922
 ] 

ASF GitHub Bot commented on DRILL-4280:
---------------------------------------

Github user sudheeshkatkam commented on a diff in the pull request:

    https://github.com/apache/drill/pull/578#discussion_r85853194
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserAuthenticationUtil.java
 ---
    @@ -0,0 +1,248 @@
    +/**
    + * 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.drill.exec.rpc.user;
    +
    +import com.google.common.base.Function;
    +import com.google.common.base.Strings;
    +import com.google.common.collect.ImmutableSet;
    +import com.google.common.collect.Iterators;
    +import org.apache.drill.common.KerberosUtil;
    +import org.apache.drill.common.config.ConnectionParameters;
    +import org.apache.hadoop.conf.Configuration;
    +import org.apache.hadoop.fs.CommonConfigurationKeys;
    +import org.apache.hadoop.security.UserGroupInformation;
    +
    +import javax.annotation.Nullable;
    +import javax.security.auth.callback.Callback;
    +import javax.security.auth.callback.CallbackHandler;
    +import javax.security.auth.callback.NameCallback;
    +import javax.security.auth.callback.PasswordCallback;
    +import javax.security.auth.callback.UnsupportedCallbackException;
    +import javax.security.auth.login.LoginException;
    +import javax.security.sasl.Sasl;
    +import javax.security.sasl.SaslClient;
    +import javax.security.sasl.SaslException;
    +import java.io.IOException;
    +import java.lang.reflect.UndeclaredThrowableException;
    +import java.security.PrivilegedExceptionAction;
    +import java.util.List;
    +import java.util.Set;
    +
    +public final class UserAuthenticationUtil {
    +  private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(UserAuthenticationUtil.class);
    +
    +  private static final String PLAIN_MECHANISM = "PLAIN";
    +
    +  private static final String DEFAULT_SERVICE_NAME = 
System.getProperty("service.name.primary", "drill");
    +
    +  private static final String DEFAULT_REALM_NAME = 
System.getProperty("service.name.realm", "default");
    +
    +  public enum ClientAuthenticationProvider {
    +
    +    KERBEROS {
    +      @Override
    +      public UserGroupInformation login(final ConnectionParameters 
parameters) throws SaslException {
    +        final Configuration conf = new Configuration();
    +        conf.set(CommonConfigurationKeys.HADOOP_SECURITY_AUTHENTICATION,
    +            UserGroupInformation.AuthenticationMethod.KERBEROS.toString());
    +        UserGroupInformation.setConfiguration(conf);
    +
    +        final String keytab = 
parameters.getParameter(ConnectionParameters.KEYTAB);
    +        try {
    +          final UserGroupInformation ugi;
    +          if (keytab != null) {
    +            ugi = UserGroupInformation.loginUserFromKeytabAndReturnUGI(
    +                parameters.getParameter(ConnectionParameters.USER), 
keytab);
    +            logger.debug("Logged in using keytab.");
    +          } else {
    +            // includes Kerberos ticket login
    +            ugi = UserGroupInformation.getCurrentUser();
    +            logger.debug("Logged in using ticket.");
    +          }
    +          return ugi;
    +        } catch (final IOException e) {
    +          logger.debug("Login failed.", e);
    +          final Throwable cause = e.getCause();
    +          if (cause instanceof LoginException) {
    +            throw new SaslException("Failed to login.", cause);
    +          }
    +          throw new SaslException("Unexpected failure trying to login: " + 
cause.getMessage());
    --- End diff --
    
    Done.


> Kerberos Authentication
> -----------------------
>
>                 Key: DRILL-4280
>                 URL: https://issues.apache.org/jira/browse/DRILL-4280
>             Project: Apache Drill
>          Issue Type: Improvement
>            Reporter: Keys Botzum
>            Assignee: Chunhui Shi
>              Labels: security
>
> Drill should support Kerberos based authentication from clients. This means 
> that both the ODBC and JDBC drivers as well as the web/REST interfaces should 
> support inbound Kerberos. For Web this would most likely be SPNEGO while for 
> ODBC and JDBC this will be more generic Kerberos.
> Since Hive and much of Hadoop supports Kerberos there is a potential for a 
> lot of reuse of ideas if not implementation.
> Note that this is related to but not the same as 
> https://issues.apache.org/jira/browse/DRILL-3584 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to