|
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.CommonConfigurationKeys;
|
|
|
import org.apache.hadoop.security.KerberosInfo;
|
|
|
+import org.apache.hadoop.security.KerberosName;
|
|
|
import org.apache.hadoop.security.SecurityUtil;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
|
|
@@ -35,6 +36,8 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|
|
*/
|
|
|
public class ServiceAuthorizationManager {
|
|
|
private static final String HADOOP_POLICY_FILE = "hadoop-policy.xml";
|
|
|
+ private static final Log LOG = LogFactory
|
|
|
+ .getLog(ServiceAuthorizationManager.class);
|
|
|
|
|
|
private static Map<Class<?>, AccessControlList> protocolToAcl =
|
|
|
new IdentityHashMap<Class<?>, AccessControlList>();
|
|
@@ -97,7 +100,19 @@ public class ServiceAuthorizationManager {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if((clientPrincipal != null && !clientPrincipal.equals(user.getUserName())) ||
|
|
|
+ // when authorizing use the short name only
|
|
|
+ String shortName = clientPrincipal;
|
|
|
+ if(clientPrincipal != null ) {
|
|
|
+ try {
|
|
|
+ shortName = new KerberosName(clientPrincipal).getShortName();
|
|
|
+ } catch (IOException e) {
|
|
|
+ LOG.warn("couldn't get short name from " + clientPrincipal, e);
|
|
|
+ // just keep going
|
|
|
+ }
|
|
|
+ }
|
|
|
+ LOG.debug("for protocol authorization compare (" + clientPrincipal + "): "
|
|
|
+ + shortName + " with " + user.getShortUserName());
|
|
|
+ if((shortName != null && !shortName.equals(user.getShortUserName())) ||
|
|
|
!acl.isUserAllowed(user)) {
|
|
|
AUDITLOG.warn(AUTHZ_FAILED_FOR + user + " for protocol="+protocol);
|
|
|
throw new AuthorizationException("User " + user +
|