Skip to content

Commit 2c70c0f

Browse files
macroadsteraajisaka
authored andcommitted
SPNEGO TLS verification
Signed-off-by: Akira Ajisaka <[email protected]> (cherry picked from commit 81d8a88) (cherry picked from commit d73cdb1)
1 parent e6887bd commit 2c70c0f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/web/WebHdfsFileSystem.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ public class WebHdfsFileSystem extends FileSystem
152152
+ "/v" + VERSION;
153153
public static final String EZ_HEADER = "X-Hadoop-Accept-EZ";
154154
public static final String FEFINFO_HEADER = "X-Hadoop-feInfo";
155+
public static final String DFS_HTTP_POLICY_KEY = "dfs.http.policy";
155156

156157
/**
157158
* Default connection factory may be overridden in tests to use smaller
@@ -181,6 +182,7 @@ public class WebHdfsFileSystem extends FileSystem
181182

182183
private DFSOpsCountStatistics storageStatistics;
183184
private KeyProvider testProvider;
185+
private boolean isTLSKrb;
184186

185187
/**
186188
* Return the protocol scheme for the FileSystem.
@@ -242,6 +244,7 @@ public synchronized void initialize(URI uri, Configuration conf
242244
.newDefaultURLConnectionFactory(connectTimeout, readTimeout, conf);
243245
}
244246

247+
this.isTLSKrb = "HTTPS_ONLY".equals(conf.get(DFS_HTTP_POLICY_KEY));
245248

246249
ugi = UserGroupInformation.getCurrentUser();
247250
this.uri = URI.create(uri.getScheme() + "://" + uri.getAuthority());
@@ -699,6 +702,11 @@ protected HttpURLConnection connect(URL url) throws IOException {
699702
//redirect hostname and port
700703
redirectHost = null;
701704

705+
if (url.getProtocol().equals("http") &&
706+
UserGroupInformation.isSecurityEnabled() &&
707+
isTLSKrb) {
708+
throw new IOException("Access denied: dfs.http.policy is HTTPS_ONLY.");
709+
}
702710

703711
// resolve redirects for a DN operation unless already resolved
704712
if (op.getRedirect() && !redirected) {

0 commit comments

Comments
 (0)