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

    https://github.com/apache/drill/pull/578#discussion_r102348994
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/rpc/user/UserServer.java ---
    @@ -358,25 +291,59 @@ public BitToUserHandshake 
getHandshakeResponse(UserToBitHandshake inbound) throw
                 return handleFailure(respBuilder, 
HandshakeStatus.RPC_VERSION_MISMATCH, errMsg, null);
               }
     
    -          if (authenticator != null) {
    +          connection.setHandshake(inbound);
    +
    +          if (!config.isAuthEnabled()) {
    +            
connection.finalizeSession(inbound.getCredentials().getUserName());
    +            respBuilder.setStatus(HandshakeStatus.SUCCESS);
    +            return respBuilder.build();
    +          }
    +
    +          final boolean clientSupportsSasl = inbound.hasSaslSupport() &&
    +              (inbound.getSaslSupport().ordinal() >= 
SaslSupport.SASL_AUTH.ordinal());
    +          if (!clientSupportsSasl) { // for backward compatibility < 1.10
    +            final String userName = inbound.getCredentials().getUserName();
    +            if (logger.isTraceEnabled()) {
    +              logger.trace("User {} on connection {} is likely using an 
older client.",
    +                  userName, connection.getRemoteAddress());
    +            }
                 try {
                   String password = "";
                   final UserProperties props = inbound.getProperties();
                   for (int i = 0; i < props.getPropertiesCount(); i++) {
                     Property prop = props.getProperties(i);
    -                if (UserSession.PASSWORD.equalsIgnoreCase(prop.getKey())) {
    +                if 
(DrillProperties.PASSWORD.equalsIgnoreCase(prop.getKey())) {
                       password = prop.getValue();
                       break;
                     }
                   }
    -              
authenticator.authenticate(inbound.getCredentials().getUserName(), password);
    +              final PlainFactory plainFactory = 
config.getAuthProvider().getPlainFactory();
    +              if (plainFactory == null) {
    +                throw new UserAuthenticationException("The server no 
longer supports username/password" +
    +                    " based authentication. Please talk to your system 
administrator.");
    +              }
    +              plainFactory.getAuthenticator()
    +                  .authenticate(userName, password);
    +              connection.changeHandlerTo(config.getMessageHandler());
    +              connection.finalizeSession(userName);
    +              respBuilder.setStatus(HandshakeStatus.SUCCESS);
    +              if (logger.isTraceEnabled()) {
    +                logger.trace("Authenticated {} successfully using PLAIN 
from {}", userName,
    +                    connection.getRemoteAddress());
    +              }
    +              return respBuilder.build();
                 } catch (UserAuthenticationException ex) {
                   return handleFailure(respBuilder, 
HandshakeStatus.AUTH_FAILED, ex.getMessage(), ex);
                 }
               }
     
    -          connection.setUser(inbound);
    -          return respBuilder.setStatus(HandshakeStatus.SUCCESS).build();
    +          // mention server's authentication capabilities
    +          
respBuilder.addAllAuthenticationMechanisms(config.getAuthProvider().getAllFactoryNames());
    +
    +          // for now, this means PLAIN credentials will be sent over twice
    --- End diff --
    
    just a thought if this is something you're worried about. What prevents the 
server to detect the plain credentials from the user, and try to perform the 
authentication directly (if plain is supported)?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to