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

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 8cf2c3cbbe5 Add ShardingSphereUser.authenticationMethodName (#24116)
8cf2c3cbbe5 is described below

commit 8cf2c3cbbe5ba57e9e811f46a8a1351517077825
Author: Liang Zhang <[email protected]>
AuthorDate: Sat Feb 11 17:06:22 2023 +0800

    Add ShardingSphereUser.authenticationMethodName (#24116)
---
 .../shardingsphere/infra/metadata/user/ShardingSphereUser.java     | 7 +++++++
 .../infra/metadata/user/yaml/config/YamlUserConfiguration.java     | 2 ++
 .../infra/metadata/user/yaml/swapper/YamlUserSwapper.java          | 3 ++-
 .../frontend/mysql/authentication/MySQLAuthenticationHandler.java  | 1 -
 .../postgresql/authentication/PostgreSQLAuthenticationHandler.java | 1 -
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/ShardingSphereUser.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/ShardingSphereUser.java
index 4b857b3ba5d..2077f6d91fb 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/ShardingSphereUser.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/ShardingSphereUser.java
@@ -31,8 +31,15 @@ public final class ShardingSphereUser {
     
     private final String password;
     
+    private final String authenticationMethodName;
+    
     public ShardingSphereUser(final String username, final String password, 
final String hostname) {
+        this(username, password, hostname, null);
+    }
+    
+    public ShardingSphereUser(final String username, final String password, 
final String hostname, final String authenticationMethodName) {
         grantee = new Grantee(username, hostname);
         this.password = password;
+        this.authenticationMethodName = authenticationMethodName;
     }
 }
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/config/YamlUserConfiguration.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/config/YamlUserConfiguration.java
index 47518666d8f..7b5cf551c69 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/config/YamlUserConfiguration.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/config/YamlUserConfiguration.java
@@ -32,6 +32,8 @@ public final class YamlUserConfiguration implements 
YamlConfiguration {
     
     private String password;
     
+    private String authenticationMethodName;
+    
     @Override
     public String toString() {
         return user.contains("@") ? user + ":" + password : user + "@%:" + 
password;
diff --git 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/swapper/YamlUserSwapper.java
 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/swapper/YamlUserSwapper.java
index d615119822d..72ce25d3bcb 100644
--- 
a/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/swapper/YamlUserSwapper.java
+++ 
b/infra/common/src/main/java/org/apache/shardingsphere/infra/metadata/user/yaml/swapper/YamlUserSwapper.java
@@ -39,6 +39,7 @@ public final class YamlUserSwapper implements 
YamlConfigurationSwapper<YamlUserC
         YamlUserConfiguration result = new YamlUserConfiguration();
         result.setUser(data.getGrantee().toString());
         result.setPassword(data.getPassword());
+        result.setAuthenticationMethodName(data.getAuthenticationMethodName());
         return result;
     }
     
@@ -48,7 +49,7 @@ public final class YamlUserSwapper implements 
YamlConfigurationSwapper<YamlUserC
             return null;
         }
         Grantee grantee = convertYamlUserToGrantee(yamlConfig.getUser());
-        return new ShardingSphereUser(grantee.getUsername(), 
yamlConfig.getPassword(), grantee.getHostname());
+        return new ShardingSphereUser(grantee.getUsername(), 
yamlConfig.getPassword(), grantee.getHostname(), 
yamlConfig.getAuthenticationMethodName());
     }
     
     private Grantee convertYamlUserToGrantee(final String yamlUser) {
diff --git 
a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
 
b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
index 875f322e05f..8cf729cbf0b 100644
--- 
a/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
+++ 
b/proxy/frontend/mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
@@ -64,7 +64,6 @@ public final class MySQLAuthenticationHandler {
      * @return authenticator
      */
     public MySQLAuthenticator getAuthenticator(final Grantee grantee) {
-        // TODO get authenticator by grantee
         return new MySQLNativePasswordAuthenticator(authPluginData);
     }
 }
diff --git 
a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
 
b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
index 67109becb2b..58b8bd52cbe 100644
--- 
a/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
+++ 
b/proxy/frontend/postgresql/src/main/java/org/apache/shardingsphere/proxy/frontend/postgresql/authentication/PostgreSQLAuthenticationHandler.java
@@ -66,7 +66,6 @@ public final class PostgreSQLAuthenticationHandler {
      * @return authenticator
      */
     public PostgreSQLAuthenticator getAuthenticator(final Grantee grantee) {
-        // TODO get authenticator by grantee
         return new PostgreSQLMD5PasswordAuthenticator();
     }
 }

Reply via email to