pan3793 commented on code in PR #5961:
URL: https://github.com/apache/kyuubi/pull/5961#discussion_r1449743560


##########
kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java:
##########
@@ -861,7 +861,9 @@ && hasSessionValue(AUTH_PRINCIPAL)
         && !hasSessionValue(AUTH_KYUUBI_CLIENT_KEYTAB)
         && (AUTH_KERBEROS_AUTH_TYPE_FROM_SUBJECT.equalsIgnoreCase(
                 sessConfMap.get(AUTH_KERBEROS_AUTH_TYPE))
-            || isHadoopUserGroupInformationDoAs());
+            || (!AUTH_KERBEROS_AUTH_TYPE_FROM_TICKET_CACHE.equalsIgnoreCase(
+                    sessConfMap.get(AUTH_KERBEROS_AUTH_TYPE))
+                && isHadoopUserGroupInformationDoAs()));

Review Comment:
   maybe something like
   ```java
     private boolean isForciblyFromKeytabAuthMode() {
       return 
"fromKeytab".equalsIgnoreCase(sessConfMap.get("kerberosAuthType"));
     }
   
     private boolean isForciblyFromSubjectAuthMode() {
       return 
"fromSubject".equalsIgnoreCase(sessConfMap.get("kerberosAuthType"));
     }
   
     private boolean isForciblyTgtCacheAuthMode() {
       return 
"fromTicketCache".equalsIgnoreCase(sessConfMap.get("kerberosAuthType"));
     }
   
     private boolean isKeytabAuthMode() {
       // handle explicit cases first
       if (isForciblyFromSubjectAuthMode() || isForciblyTgtCacheAuthMode()) {
         return false;
       }
       if (isKerberosAuthMode() && isForciblyFromKeytabAuthMode()) {
         return true;
       }
       // handle implicit cases then
       return isKerberosAuthMode()
           && hasSessionValue(AUTH_KYUUBI_CLIENT_PRINCIPAL)
           && hasSessionValue(AUTH_KYUUBI_CLIENT_KEYTAB);
     }
   
     private boolean isFromSubjectAuthMode() {
       // handle explicit cases first
       if (isForciblyFromKeytabAuthMode() || isForciblyTgtCacheAuthMode()) {
         return false;
       }
       if (isKerberosAuthMode() && isForciblyFromSubjectAuthMode()) {
         return true;
       }
       // handle implicit cases then
       return isKerberosAuthMode()
           && !hasSessionValue(AUTH_KYUUBI_CLIENT_KEYTAB)
           && isHadoopUserGroupInformationDoAs();
     }
   
     private boolean isTgtCacheAuthMode() {
       // handle explicit cases first
       if (isForciblyFromKeytabAuthMode() || isForciblyFromSubjectAuthMode()) {
         return false;
       }
       if (isKerberosAuthMode() && isForciblyTgtCacheAuthMode()) {
         return true;
       }
       // handle implicit cases then
       return isKerberosAuthMode()
           && !hasSessionValue(AUTH_KYUUBI_CLIENT_KEYTAB);
     }
   ```



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