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


##########
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:
   Yes, it seems that this solves the problem. Thanks for the suggestion!  
   I will update the PR, but I also want to fix the other failed unit test.



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