HADOOP-19227. ipc.Server accelerate token negotiation only for the default mechanism. (#6949)
This commit is contained in:
parent
7638b4727e
commit
9dad697dbc
@ -106,6 +106,7 @@
|
|||||||
import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RPCTraceInfoProto;
|
import org.apache.hadoop.ipc.protobuf.RpcHeaderProtos.RPCTraceInfoProto;
|
||||||
import org.apache.hadoop.net.NetUtils;
|
import org.apache.hadoop.net.NetUtils;
|
||||||
import org.apache.hadoop.security.AccessControlException;
|
import org.apache.hadoop.security.AccessControlException;
|
||||||
|
import org.apache.hadoop.security.SaslConstants;
|
||||||
import org.apache.hadoop.security.SaslPropertiesResolver;
|
import org.apache.hadoop.security.SaslPropertiesResolver;
|
||||||
import org.apache.hadoop.security.SaslRpcServer;
|
import org.apache.hadoop.security.SaslRpcServer;
|
||||||
import org.apache.hadoop.security.SaslRpcServer.AuthMethod;
|
import org.apache.hadoop.security.SaslRpcServer.AuthMethod;
|
||||||
@ -2604,7 +2605,8 @@ private RpcSaslProto buildSaslNegotiateResponse()
|
|||||||
RpcSaslProto negotiateMessage = negotiateResponse;
|
RpcSaslProto negotiateMessage = negotiateResponse;
|
||||||
// accelerate token negotiation by sending initial challenge
|
// accelerate token negotiation by sending initial challenge
|
||||||
// in the negotiation response
|
// in the negotiation response
|
||||||
if (enabledAuthMethods.contains(AuthMethod.TOKEN)) {
|
if (enabledAuthMethods.contains(AuthMethod.TOKEN)
|
||||||
|
&& SaslConstants.SASL_MECHANISM_DEFAULT.equals(AuthMethod.TOKEN.getMechanismName())) {
|
||||||
saslServer = createSaslServer(AuthMethod.TOKEN);
|
saslServer = createSaslServer(AuthMethod.TOKEN);
|
||||||
byte[] challenge = saslServer.evaluateResponse(new byte[0]);
|
byte[] challenge = saslServer.evaluateResponse(new byte[0]);
|
||||||
RpcSaslProto.Builder negotiateBuilder =
|
RpcSaslProto.Builder negotiateBuilder =
|
||||||
|
@ -32,7 +32,7 @@ public class SaslConstants {
|
|||||||
|
|
||||||
private static final String SASL_MECHANISM_ENV = "HADOOP_SASL_MECHANISM";
|
private static final String SASL_MECHANISM_ENV = "HADOOP_SASL_MECHANISM";
|
||||||
public static final String SASL_MECHANISM;
|
public static final String SASL_MECHANISM;
|
||||||
private static final String SASL_MECHANISM_DEFAULT = "DIGEST-MD5";
|
public static final String SASL_MECHANISM_DEFAULT = "DIGEST-MD5";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final String mechanism = System.getenv(SASL_MECHANISM_ENV);
|
final String mechanism = System.getenv(SASL_MECHANISM_ENV);
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
import javax.security.auth.callback.PasswordCallback;
|
import javax.security.auth.callback.PasswordCallback;
|
||||||
import javax.security.auth.callback.UnsupportedCallbackException;
|
import javax.security.auth.callback.UnsupportedCallbackException;
|
||||||
import javax.security.auth.kerberos.KerberosPrincipal;
|
import javax.security.auth.kerberos.KerberosPrincipal;
|
||||||
|
import javax.security.sasl.AuthorizeCallback;
|
||||||
import javax.security.sasl.RealmCallback;
|
import javax.security.sasl.RealmCallback;
|
||||||
import javax.security.sasl.RealmChoiceCallback;
|
import javax.security.sasl.RealmChoiceCallback;
|
||||||
import javax.security.sasl.Sasl;
|
import javax.security.sasl.Sasl;
|
||||||
@ -681,9 +682,17 @@ public void handle(Callback[] callbacks)
|
|||||||
pc = (PasswordCallback) callback;
|
pc = (PasswordCallback) callback;
|
||||||
} else if (callback instanceof RealmCallback) {
|
} else if (callback instanceof RealmCallback) {
|
||||||
rc = (RealmCallback) callback;
|
rc = (RealmCallback) callback;
|
||||||
|
} else if (callback instanceof AuthorizeCallback) {
|
||||||
|
final AuthorizeCallback ac = (AuthorizeCallback) callback;
|
||||||
|
final String authId = ac.getAuthenticationID();
|
||||||
|
final String authzId = ac.getAuthorizationID();
|
||||||
|
ac.setAuthorized(authId.equals(authzId));
|
||||||
|
if (ac.isAuthorized()) {
|
||||||
|
ac.setAuthorizedID(authzId);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedCallbackException(callback,
|
throw new UnsupportedCallbackException(callback,
|
||||||
"Unrecognized SASL client callback");
|
"Unrecognized SASL client callback " + callback.getClass());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nc != null) {
|
if (nc != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user