dengzhhu653 commented on code in PR #4666:
URL: https://github.com/apache/hive/pull/4666#discussion_r1317270578


##########
service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpServlet.java:
##########
@@ -755,34 +760,39 @@ private String getAuthHeader(HttpServletRequest request)
     return authHeaderBase64String;
   }
 
-  private boolean isAuthTypeEnabled(HttpServletRequest request,
+  @VisibleForTesting
+  boolean isAuthTypeEnabled(HttpServletRequest request,
       HiveAuthConstants.AuthTypes authType) {
-    String authMethod = request.getHeader(AUTH_TYPE);
 
-    if (authType.getAuthName().equalsIgnoreCase(authMethod) && 
this.authType.isEnabled(authType) ||
-        "UIDPWD".equalsIgnoreCase(authMethod) && 
this.authType.isPasswordBasedAuth(authType)) {
-      // Request has already set the "auth" header
+    if (hasAuthScheme(request, HttpAuthUtils.BASIC) && 
this.authType.isPasswordBasedAuth(authType)
+        && this.authType.isEnabled(authType)) {
+      // The "Authorization: Basic" scheme indicates password-based 
authentication.
+      return true;
+    }
+    String delegationToken = request.getHeader(HIVE_DELEGATION_TOKEN_HEADER);
+    if (this.authType.isEnabled(HiveAuthConstants.AuthTypes.KERBEROS) &&
+       authType == HiveAuthConstants.AuthTypes.KERBEROS &&
+       delegationToken != null && !delegationToken.isEmpty()) {
+      // Hive delegation token indicates Kerberos authentication.
+      return true;
+    }
+    if (this.authType.isEnabled(HiveAuthConstants.AuthTypes.KERBEROS) &&
+        authType == HiveAuthConstants.AuthTypes.KERBEROS &&
+        hasAuthScheme(request, HttpAuthUtils.NEGOTIATE)) {
+      // The "Authorization: Negotiate" scheme indicates Kerberos 
authentication.
+      return true;
+    }
+    if (this.authType.isEnabled(HiveAuthConstants.AuthTypes.SAML) &&
+        authType == HiveAuthConstants.AuthTypes.SAML &&
+        hasAuthScheme(request, HttpAuthUtils.BEARER) && !hasJWT(request)) {

Review Comment:
   Some tests in TestHttpSamlAuthentication failed, the request doesn't always 
have the `HttpAuthUtils.BEARER` header:
   
https://github.com/apache/hive/blob/master/jdbc/src/java/org/apache/hive/jdbc/saml/HttpSamlAuthRequestInterceptor.java#L63-L64
   Maybe we need to add the check `HiveSamlUtils.SSO_TOKEN_RESPONSE_PORT` if 
the BEARER header is absent.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to