This is an automated email from the ASF dual-hosted git repository.

chengpan pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/kyuubi.git


The following commit(s) were added to refs/heads/branch-1.8 by this push:
     new 94df5dea4 [KYUUBI #5568][FOLLOWUP] Fix security enabled judgement
94df5dea4 is described below

commit 94df5dea46d75d9f5ae6c6713912f172c1be23eb
Author: Cheng Pan <[email protected]>
AuthorDate: Thu Nov 2 13:30:09 2023 +0800

    [KYUUBI #5568][FOLLOWUP] Fix security enabled judgement
    
    ### _Why are the changes needed?_
    
    There are two enumeration classes, AuthTypes and AuthMethods, the previous 
PR messed it up ...
    
    ### _How was this patch tested?_
    - [ ] Add some test cases that check the changes thoroughly including 
negative and positive cases if possible
    
    - [ ] Add screenshots for manual tests if appropriate
    
    - [x] [Run 
test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests)
 locally before make a pull request
    
    I also tested it local by building a binary dist and running with auth NONE
    
    ### _Was this patch authored or co-authored using generative AI tooling?_
    
    No
    
    Closes #5604 from pan3793/auth-check.
    
    Closes #5568
    
    e41c2ab1d [Cheng Pan] [KYUUBI #5568][FOLLOWUP] Fix security enabled 
judgement
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
    (cherry picked from commit eaad0933176113eed63cc9aa4e5918277d7b282b)
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../kyuubi/service/authentication/KyuubiAuthenticationFactory.scala  | 3 ++-
 .../scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala   | 5 ++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/KyuubiAuthenticationFactory.scala
 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/KyuubiAuthenticationFactory.scala
index 2f56f3e4c..327d80f3e 100644
--- 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/KyuubiAuthenticationFactory.scala
+++ 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/service/authentication/KyuubiAuthenticationFactory.scala
@@ -153,7 +153,8 @@ object KyuubiAuthenticationFactory extends Logging {
   }
 
   def getValidPasswordAuthMethod(authTypes: Set[AuthType]): AuthMethod = {
-    if (authTypes.contains(NONE)) AuthMethods.NONE
+    if (authTypes == Set(NOSASL)) AuthMethods.NONE
+    else if (authTypes.contains(NONE)) AuthMethods.NONE
     else if (authTypes.contains(LDAP)) AuthMethods.LDAP
     else if (authTypes.contains(JDBC)) AuthMethods.JDBC
     else if (authTypes.contains(CUSTOM)) AuthMethods.CUSTOM
diff --git 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
index f7a09ee25..5335ff61a 100644
--- 
a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
+++ 
b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/KyuubiRestFrontendService.scala
@@ -35,8 +35,7 @@ import org.apache.kyuubi.server.api.v1.ApiRootResource
 import org.apache.kyuubi.server.http.authentication.{AuthenticationFilter, 
KyuubiHttpAuthenticationFactory}
 import org.apache.kyuubi.server.ui.{JettyServer, JettyUtils}
 import org.apache.kyuubi.service.{AbstractFrontendService, Serverable, 
Service, ServiceUtils}
-import org.apache.kyuubi.service.authentication.{AuthTypes, 
KyuubiAuthenticationFactory}
-import org.apache.kyuubi.service.authentication.AuthTypes.NONE
+import org.apache.kyuubi.service.authentication.{AuthMethods, AuthTypes, 
KyuubiAuthenticationFactory}
 import org.apache.kyuubi.session.{KyuubiSessionManager, SessionHandle}
 import org.apache.kyuubi.util.ThreadUtils
 
@@ -73,7 +72,7 @@ class KyuubiRestFrontendService(override val serverable: 
Serverable)
 
   private lazy val securityEnabled = {
     val authTypes = conf.get(AUTHENTICATION_METHOD).map(AuthTypes.withName)
-    KyuubiAuthenticationFactory.getValidPasswordAuthMethod(authTypes) != NONE
+    KyuubiAuthenticationFactory.getValidPasswordAuthMethod(authTypes) != 
AuthMethods.NONE
   }
 
   private lazy val administrators: Set[String] =

Reply via email to