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


##########
service/src/java/org/apache/hive/service/cli/thrift/ThriftHttpServlet.java:
##########
@@ -755,34 +760,46 @@ private String getAuthHeader(HttpServletRequest request)
     return authHeaderBase64String;
   }
 
-  private boolean isAuthTypeEnabled(HttpServletRequest request,
+  @VisibleForTesting
+  public 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)) {
+      // The "Authorization: Bearer <SAML TOKEN>" scheme indicates SAML 
authentication.
+      return true;
+    }
+    String ssoTokenResponsePort = 
request.getHeader(HiveSamlUtils.SSO_TOKEN_RESPONSE_PORT);
+    if (this.authType.isEnabled(HiveAuthConstants.AuthTypes.SAML) &&
+            authType == HiveAuthConstants.AuthTypes.SAML &&

Review Comment:
   nit: extra spaces



-- 
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