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

albumenj pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new a25b21facd Support basic auth (#14644)
a25b21facd is described below

commit a25b21facd6ad74a4116424a74c8a0baf7a80d18
Author: Albumen Kevin <[email protected]>
AuthorDate: Sat Sep 7 09:11:08 2024 +0800

    Support basic auth (#14644)
    
    * Support basic auth
    
    * Fix sd
    
    * Use trie
    
    * Fix ut
    
    * Fix ut
    
    * Fix ut
---
 .../dubbo/config/AbstractInterfaceConfig.java      | 42 ++++++++++
 .../apache/dubbo/auth/AccessKeyAuthenticator.java  | 14 ++--
 .../org/apache/dubbo/auth/BasicAuthenticator.java  | 53 +++++++++++++
 .../main/java/org/apache/dubbo/auth/Constants.java | 17 +++-
 .../dubbo/auth/filter/ConsumerSignFilter.java      | 16 ++--
 .../dubbo/auth/filter/ProviderAuthFilter.java      | 19 +++--
 .../auth/filter/ProviderAuthHeaderFilter.java      | 64 +++++++++++++++
 .../apache/dubbo/auth/spi/AccessKeyStorage.java    |  3 +-
 .../org/apache/dubbo/auth/spi/Authenticator.java   |  3 +-
 .../org.apache.dubbo.auth.spi.Authenticator        |  3 +-
 .../internal/org.apache.dubbo.rpc.HeaderFilter     |  1 +
 .../dubbo/auth/AccessKeyAuthenticatorTest.java     | 29 +------
 .../dubbo/auth/filter/ConsumerSignFilterTest.java  |  9 ++-
 .../dubbo/auth/filter/ProviderAuthFilterTest.java  | 36 +++++----
 .../registry/client/metadata/MetadataUtils.java    | 23 ++++++
 .../registry/integration/RegistryProtocol.java     | 34 +++++++-
 .../main/java/org/apache/dubbo/rpc/Constants.java  |  5 +-
 .../org/apache/dubbo/rpc/filter/ContextFilter.java | 74 +++++++++++++----
 .../org/apache/dubbo/rpc/support/TrieTree.java     | 92 ++++++++++++++++++++++
 .../org/apache/dubbo/rpc/support/TrieTreeTest.java | 63 +++++++++++++++
 .../java/org/apache/dubbo/rpc/TriRpcStatus.java    |  4 +
 .../dubbo/rpc/protocol/tri/TripleHeaderEnum.java   | 61 --------------
 .../dubbo/rpc/protocol/tri/TripleProtocol.java     |  3 -
 23 files changed, 510 insertions(+), 158 deletions(-)

diff --git 
a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
 
b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
index 4dd3503472..1015f124a3 100644
--- 
a/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
+++ 
b/dubbo-common/src/main/java/org/apache/dubbo/config/AbstractInterfaceConfig.java
@@ -206,6 +206,21 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
      */
     private Boolean auth;
 
+    /**
+     * Authenticator for authentication
+     */
+    private String authenticator;
+
+    /**
+     * Username for basic authenticator
+     */
+    private String username;
+
+    /**
+     * Password for basic authenticator
+     */
+    private String password;
+
     /**
      * Use separate instances for services with the same serviceKey (applies 
when using ReferenceConfig and SimpleReferenceCache together).
      * Directly calling ReferenceConfig.get() will not check this attribute.
@@ -892,6 +907,33 @@ public abstract class AbstractInterfaceConfig extends 
AbstractMethodConfig {
         this.auth = auth;
     }
 
+    public String getAuthenticator() {
+        return authenticator;
+    }
+
+    public AbstractInterfaceConfig setAuthenticator(String authenticator) {
+        this.authenticator = authenticator;
+        return this;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public AbstractInterfaceConfig setUsername(String username) {
+        this.username = username;
+        return this;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public AbstractInterfaceConfig setPassword(String password) {
+        this.password = password;
+        return this;
+    }
+
     public SslConfig getSslConfig() {
         return getConfigManager().getSsl().orElse(null);
     }
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
index 0b642b5e61..ce5d20aff9 100644
--- 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/AccessKeyAuthenticator.java
@@ -26,14 +26,14 @@ import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.common.utils.StringUtils;
 import org.apache.dubbo.rpc.Invocation;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
 import org.apache.dubbo.rpc.support.RpcUtils;
 
 public class AccessKeyAuthenticator implements Authenticator {
-    private final ApplicationModel applicationModel;
+    private final FrameworkModel frameworkModel;
 
-    public AccessKeyAuthenticator(ApplicationModel applicationModel) {
-        this.applicationModel = applicationModel;
+    public AccessKeyAuthenticator(FrameworkModel frameworkModel) {
+        this.frameworkModel = frameworkModel;
     }
 
     @Override
@@ -73,7 +73,7 @@ public class AccessKeyAuthenticator implements Authenticator {
     }
 
     AccessKeyPair getAccessKeyPair(Invocation invocation, URL url) {
-        AccessKeyStorage accessKeyStorage = applicationModel
+        AccessKeyStorage accessKeyStorage = frameworkModel
                 .getExtensionLoader(AccessKeyStorage.class)
                 
.getExtension(url.getParameter(Constants.ACCESS_KEY_STORAGE_KEY, 
Constants.DEFAULT_ACCESS_KEY_STORAGE));
 
@@ -97,10 +97,6 @@ public class AccessKeyAuthenticator implements Authenticator 
{
                 RpcUtils.getMethodName(invocation),
                 secretKey,
                 time);
-        boolean parameterEncrypt = 
url.getParameter(Constants.PARAMETER_SIGNATURE_ENABLE_KEY, false);
-        if (parameterEncrypt) {
-            return SignatureUtils.sign(invocation.getArguments(), 
requestString, secretKey);
-        }
         return SignatureUtils.sign(requestString, secretKey);
     }
 }
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/BasicAuthenticator.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/BasicAuthenticator.java
new file mode 100644
index 0000000000..b155e67da5
--- /dev/null
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/BasicAuthenticator.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.auth;
+
+import org.apache.dubbo.auth.exception.RpcAuthenticationException;
+import org.apache.dubbo.auth.spi.Authenticator;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.rpc.Invocation;
+
+import java.util.Base64;
+import java.util.Objects;
+
+public class BasicAuthenticator implements Authenticator {
+
+    @Override
+    public void sign(Invocation invocation, URL url) {
+        String username = url.getParameter(Constants.USERNAME_KEY);
+        String password = url.getParameter(Constants.PASSWORD_KEY);
+        String auth = username + ":" + password;
+        String encodedAuth = 
Base64.getEncoder().encodeToString(auth.getBytes());
+        String authHeaderValue = "Basic " + encodedAuth;
+
+        invocation.setAttachment(Constants.AUTHORIZATION_HEADER_LOWER, 
authHeaderValue);
+    }
+
+    @Override
+    public void authenticate(Invocation invocation, URL url) throws 
RpcAuthenticationException {
+        String username = url.getParameter(Constants.USERNAME_KEY);
+        String password = url.getParameter(Constants.PASSWORD_KEY);
+        String auth = username + ":" + password;
+        String encodedAuth = 
Base64.getEncoder().encodeToString(auth.getBytes());
+        String authHeaderValue = "Basic " + encodedAuth;
+
+        if (!Objects.equals(authHeaderValue, 
invocation.getAttachment(Constants.AUTHORIZATION_HEADER))
+                && !Objects.equals(authHeaderValue, 
invocation.getAttachment(Constants.AUTHORIZATION_HEADER_LOWER))) {
+            throw new RpcAuthenticationException("Failed to authenticate, 
maybe consumer side did not enable the auth");
+        }
+    }
+}
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/Constants.java 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/Constants.java
index f331c0444a..1d4431001c 100644
--- a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/Constants.java
+++ b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/Constants.java
@@ -18,11 +18,15 @@ package org.apache.dubbo.auth;
 
 public interface Constants {
 
-    String SERVICE_AUTH = "auth";
+    String AUTH_KEY = "auth";
 
-    String AUTHENTICATOR = "authenticator";
+    String AUTHENTICATOR_KEY = "authenticator";
 
-    String DEFAULT_AUTHENTICATOR = "accesskey";
+    String USERNAME_KEY = "username";
+
+    String PASSWORD_KEY = "password";
+
+    String DEFAULT_AUTHENTICATOR = "basic";
 
     String DEFAULT_ACCESS_KEY_STORAGE = "urlstorage";
 
@@ -41,4 +45,11 @@ public interface Constants {
     String SIGNATURE_STRING_FORMAT = "%s#%s#%s#%s";
 
     String PARAMETER_SIGNATURE_ENABLE_KEY = "param.sign";
+
+    String AUTH_SUCCESS = "auth.success";
+
+    String AUTHORIZATION_HEADER_LOWER = "authorization";
+
+    String AUTHORIZATION_HEADER = "Authorization";
+    String REMOTE_ADDRESS_KEY = "tri.remote.address";
 }
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ConsumerSignFilter.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ConsumerSignFilter.java
index 9356e47206..0f25baf28d 100644
--- 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ConsumerSignFilter.java
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ConsumerSignFilter.java
@@ -26,29 +26,29 @@ import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Result;
 import org.apache.dubbo.rpc.RpcException;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
 
 /**
  * The ConsumerSignFilter
  *
  * @see org.apache.dubbo.rpc.Filter
  */
-@Activate(group = CommonConstants.CONSUMER, value = Constants.SERVICE_AUTH, 
order = -10000)
+@Activate(group = CommonConstants.CONSUMER, value = Constants.AUTH_KEY, order 
= -10000)
 public class ConsumerSignFilter implements Filter {
-    private final ApplicationModel applicationModel;
+    private final FrameworkModel frameworkModel;
 
-    public ConsumerSignFilter(ApplicationModel applicationModel) {
-        this.applicationModel = applicationModel;
+    public ConsumerSignFilter(FrameworkModel frameworkModel) {
+        this.frameworkModel = frameworkModel;
     }
 
     @Override
     public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
         URL url = invoker.getUrl();
-        boolean shouldAuth = url.getParameter(Constants.SERVICE_AUTH, false);
+        boolean shouldAuth = url.getParameter(Constants.AUTH_KEY, false);
         if (shouldAuth) {
-            Authenticator authenticator = applicationModel
+            Authenticator authenticator = frameworkModel
                     .getExtensionLoader(Authenticator.class)
-                    .getExtension(url.getParameter(Constants.AUTHENTICATOR, 
Constants.DEFAULT_AUTHENTICATOR));
+                    
.getExtension(url.getParameter(Constants.AUTHENTICATOR_KEY, 
Constants.DEFAULT_AUTHENTICATOR));
             authenticator.sign(invocation, url);
         }
         return invoker.invoke(invocation);
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthFilter.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthFilter.java
index 79dc883ecd..fd2e1d6374 100644
--- 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthFilter.java
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthFilter.java
@@ -27,24 +27,27 @@ import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Result;
 import org.apache.dubbo.rpc.RpcException;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
 
-@Activate(group = CommonConstants.PROVIDER, value = Constants.SERVICE_AUTH, 
order = -10000)
+@Activate(group = CommonConstants.PROVIDER, value = Constants.AUTH_KEY, order 
= -10000)
 public class ProviderAuthFilter implements Filter {
-    private final ApplicationModel applicationModel;
+    private final FrameworkModel frameworkModel;
 
-    public ProviderAuthFilter(ApplicationModel applicationModel) {
-        this.applicationModel = applicationModel;
+    public ProviderAuthFilter(FrameworkModel frameworkModel) {
+        this.frameworkModel = frameworkModel;
     }
 
     @Override
     public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
         URL url = invoker.getUrl();
-        boolean shouldAuth = url.getParameter(Constants.SERVICE_AUTH, false);
+        boolean shouldAuth = url.getParameter(Constants.AUTH_KEY, false);
         if (shouldAuth) {
-            Authenticator authenticator = applicationModel
+            if 
(Boolean.TRUE.equals(invocation.getAttributes().get(Constants.AUTH_SUCCESS))) {
+                return invoker.invoke(invocation);
+            }
+            Authenticator authenticator = frameworkModel
                     .getExtensionLoader(Authenticator.class)
-                    .getExtension(url.getParameter(Constants.AUTHENTICATOR, 
Constants.DEFAULT_AUTHENTICATOR));
+                    
.getExtension(url.getParameter(Constants.AUTHENTICATOR_KEY, 
Constants.DEFAULT_AUTHENTICATOR));
             try {
                 authenticator.authenticate(invocation, url);
             } catch (Exception e) {
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthHeaderFilter.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthHeaderFilter.java
new file mode 100644
index 0000000000..2477e25d5b
--- /dev/null
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/filter/ProviderAuthHeaderFilter.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.auth.filter;
+
+import org.apache.dubbo.auth.Constants;
+import org.apache.dubbo.auth.spi.Authenticator;
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.rpc.HeaderFilter;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.RpcInvocation;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+import org.apache.dubbo.rpc.support.RpcUtils;
+
+import static org.apache.dubbo.rpc.RpcException.AUTHORIZATION_EXCEPTION;
+
+@Activate(value = Constants.AUTH_KEY, order = -20000)
+public class ProviderAuthHeaderFilter implements HeaderFilter {
+    private final FrameworkModel frameworkModel;
+
+    public ProviderAuthHeaderFilter(FrameworkModel frameworkModel) {
+        this.frameworkModel = frameworkModel;
+    }
+
+    @Override
+    public RpcInvocation invoke(Invoker<?> invoker, RpcInvocation invocation) 
throws RpcException {
+        URL url = invoker.getUrl();
+        boolean shouldAuth = url.getParameter(Constants.AUTH_KEY, false);
+        if (shouldAuth) {
+            Authenticator authenticator = frameworkModel
+                    .getExtensionLoader(Authenticator.class)
+                    
.getExtension(url.getParameter(Constants.AUTHENTICATOR_KEY, 
Constants.DEFAULT_AUTHENTICATOR));
+            try {
+                authenticator.authenticate(invocation, url);
+            } catch (Exception e) {
+                Class<?> serviceType = invoker.getInterface();
+                throw new RpcException(
+                        AUTHORIZATION_EXCEPTION,
+                        "Forbid invoke remote service " + serviceType + " 
method " + RpcUtils.getMethodName(invocation)
+                                + "() from consumer "
+                                + 
invocation.getAttributes().get(Constants.REMOTE_ADDRESS_KEY) + " to provider "
+                                + 
RpcContext.getServiceContext().getLocalHost());
+            }
+            invocation.getAttributes().put(Constants.AUTH_SUCCESS, 
Boolean.TRUE);
+        }
+        return invocation;
+    }
+}
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/AccessKeyStorage.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/AccessKeyStorage.java
index 19ffbdc2bc..532d5959d4 100644
--- 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/AccessKeyStorage.java
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/AccessKeyStorage.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.auth.spi;
 
 import org.apache.dubbo.auth.model.AccessKeyPair;
 import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.extension.ExtensionScope;
 import org.apache.dubbo.common.extension.SPI;
 import org.apache.dubbo.rpc.Invocation;
 
@@ -25,7 +26,7 @@ import org.apache.dubbo.rpc.Invocation;
  * This SPI Extension support us to store our {@link AccessKeyPair} or load 
{@link AccessKeyPair} from other
  * storage, such as filesystem.
  */
-@SPI
+@SPI(scope = ExtensionScope.FRAMEWORK)
 public interface AccessKeyStorage {
 
     /**
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/Authenticator.java
 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/Authenticator.java
index c8b61057b7..4718769140 100644
--- 
a/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/Authenticator.java
+++ 
b/dubbo-plugin/dubbo-auth/src/main/java/org/apache/dubbo/auth/spi/Authenticator.java
@@ -18,10 +18,11 @@ package org.apache.dubbo.auth.spi;
 
 import org.apache.dubbo.auth.exception.RpcAuthenticationException;
 import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.extension.ExtensionScope;
 import org.apache.dubbo.common.extension.SPI;
 import org.apache.dubbo.rpc.Invocation;
 
-@SPI("accessKey")
+@SPI(scope = ExtensionScope.FRAMEWORK, value = "basic")
 public interface Authenticator {
 
     /**
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.auth.spi.Authenticator
 
b/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.auth.spi.Authenticator
index b4b2fbd0f2..e3f919ac30 100644
--- 
a/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.auth.spi.Authenticator
+++ 
b/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.auth.spi.Authenticator
@@ -1 +1,2 @@
-accesskey=org.apache.dubbo.auth.AccessKeyAuthenticator
\ No newline at end of file
+accesskey=org.apache.dubbo.auth.AccessKeyAuthenticator
+basic=org.apache.dubbo.auth.BasicAuthenticator
diff --git 
a/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.HeaderFilter
 
b/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.HeaderFilter
new file mode 100644
index 0000000000..f39300eb59
--- /dev/null
+++ 
b/dubbo-plugin/dubbo-auth/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.HeaderFilter
@@ -0,0 +1 @@
+auth=org.apache.dubbo.auth.filter.ProviderAuthHeaderFilter
diff --git 
a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
 
b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
index e886d6e83d..2aca73f08b 100644
--- 
a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
+++ 
b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/AccessKeyAuthenticatorTest.java
@@ -22,15 +22,12 @@ import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.RpcInvocation;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-
-import java.util.ArrayList;
+import org.apache.dubbo.rpc.model.FrameworkModel;
 
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -95,14 +92,14 @@ class AccessKeyAuthenticatorTest {
                 .addParameter(CommonConstants.APPLICATION_KEY, "test")
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk");
         Invocation invocation = new RpcInvocation();
-        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(ApplicationModel.defaultModel());
+        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(FrameworkModel.defaultModel());
         assertThrows(RpcAuthenticationException.class, () -> 
helper.authenticate(invocation, url));
     }
 
     @Test
     void testGetAccessKeyPairFailed() {
         URL url = 
URL.valueOf("dubbo://10.10.10.10:2181").addParameter(Constants.ACCESS_KEY_ID_KEY,
 "ak");
-        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(ApplicationModel.defaultModel());
+        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(FrameworkModel.defaultModel());
         Invocation invocation = mock(Invocation.class);
         assertThrows(RuntimeException.class, () -> 
helper.getAccessKeyPair(invocation, url));
     }
@@ -112,26 +109,8 @@ class AccessKeyAuthenticatorTest {
         URL url = mock(URL.class);
         Invocation invocation = mock(Invocation.class);
         String secretKey = "123456";
-        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(ApplicationModel.defaultModel());
-        String signature = helper.getSignature(url, invocation, secretKey, 
String.valueOf(System.currentTimeMillis()));
-        assertNotNull(signature);
-    }
-
-    @Test
-    void testGetSignatureWithParameter() {
-        URL url = mock(URL.class);
-        when(url.getParameter(Constants.PARAMETER_SIGNATURE_ENABLE_KEY, 
false)).thenReturn(true);
-        Invocation invocation = mock(Invocation.class);
-        String secretKey = "123456";
-        Object[] params = {"dubbo", new ArrayList()};
-        when(invocation.getArguments()).thenReturn(params);
-        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(ApplicationModel.defaultModel());
+        AccessKeyAuthenticator helper = new 
AccessKeyAuthenticator(FrameworkModel.defaultModel());
         String signature = helper.getSignature(url, invocation, secretKey, 
String.valueOf(System.currentTimeMillis()));
         assertNotNull(signature);
-
-        Object[] fakeParams = {"dubbo1", new ArrayList<>()};
-        when(invocation.getArguments()).thenReturn(fakeParams);
-        String signature1 = helper.getSignature(url, invocation, secretKey, 
String.valueOf(System.currentTimeMillis()));
-        assertNotEquals(signature, signature1);
     }
 }
diff --git 
a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ConsumerSignFilterTest.java
 
b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ConsumerSignFilterTest.java
index 2bf31d74b9..59dbef5398 100644
--- 
a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ConsumerSignFilterTest.java
+++ 
b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ConsumerSignFilterTest.java
@@ -21,7 +21,7 @@ import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
 
 import org.junit.jupiter.api.Test;
 
@@ -41,7 +41,7 @@ class ConsumerSignFilterTest {
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(Invocation.class);
         when(invoker.getUrl()).thenReturn(url);
-        ConsumerSignFilter consumerSignFilter = new 
ConsumerSignFilter(ApplicationModel.defaultModel());
+        ConsumerSignFilter consumerSignFilter = new 
ConsumerSignFilter(FrameworkModel.defaultModel());
         consumerSignFilter.invoke(invoker, invocation);
         verify(invocation, 
never()).setAttachment(eq(Constants.REQUEST_SIGNATURE_KEY), anyString());
     }
@@ -52,11 +52,12 @@ class ConsumerSignFilterTest {
                 .addParameter(Constants.ACCESS_KEY_ID_KEY, "ak")
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test")
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(Invocation.class);
         when(invoker.getUrl()).thenReturn(url);
-        ConsumerSignFilter consumerSignFilter = new 
ConsumerSignFilter(ApplicationModel.defaultModel());
+        ConsumerSignFilter consumerSignFilter = new 
ConsumerSignFilter(FrameworkModel.defaultModel());
         consumerSignFilter.invoke(invoker, invocation);
         verify(invocation, 
times(1)).setAttachment(eq(Constants.REQUEST_SIGNATURE_KEY), anyString());
     }
diff --git 
a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ProviderAuthFilterTest.java
 
b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ProviderAuthFilterTest.java
index e0c2b5c906..725b0e4e51 100644
--- 
a/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ProviderAuthFilterTest.java
+++ 
b/dubbo-plugin/dubbo-auth/src/test/java/org/apache/dubbo/auth/filter/ProviderAuthFilterTest.java
@@ -25,7 +25,7 @@ import org.apache.dubbo.rpc.Invocation;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Result;
 import org.apache.dubbo.rpc.RpcInvocation;
-import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
 
 import org.junit.jupiter.api.Test;
 
@@ -46,9 +46,9 @@ class ProviderAuthFilterTest {
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
         when(invoker.getUrl()).thenReturn(url);
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         providerAuthFilter.invoke(invoker, invocation);
-        verify(url, never()).getParameter(eq(Constants.AUTHENTICATOR), 
eq(Constants.DEFAULT_AUTHENTICATOR));
+        verify(url, never()).getParameter(eq(Constants.AUTHENTICATOR_KEY), 
eq(Constants.DEFAULT_AUTHENTICATOR));
     }
 
     @Test
@@ -57,11 +57,12 @@ class ProviderAuthFilterTest {
                 .addParameter(Constants.ACCESS_KEY_ID_KEY, "ak")
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test")
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
         when(invoker.getUrl()).thenReturn(url);
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         providerAuthFilter.invoke(invoker, invocation);
         verify(invocation, atLeastOnce()).getAttachment(anyString());
     }
@@ -72,13 +73,14 @@ class ProviderAuthFilterTest {
                 .addParameter(Constants.ACCESS_KEY_ID_KEY, "ak")
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test")
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
         
when(invocation.getAttachment(Constants.REQUEST_SIGNATURE_KEY)).thenReturn(null);
         when(invoker.getUrl()).thenReturn(url);
 
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         Result result = providerAuthFilter.invoke(invoker, invocation);
         assertTrue(result.hasException());
     }
@@ -89,13 +91,14 @@ class ProviderAuthFilterTest {
                 .addParameter(Constants.ACCESS_KEY_ID_KEY, "ak")
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test")
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
         
when(invocation.getAttachment(Constants.REQUEST_SIGNATURE_KEY)).thenReturn(null);
         when(invoker.getUrl()).thenReturn(url);
 
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         Result result = providerAuthFilter.invoke(invoker, invocation);
         assertTrue(result.hasException());
     }
@@ -104,7 +107,8 @@ class ProviderAuthFilterTest {
     void testAuthFailedWhenNoAccessKeyPair() {
         URL url = URL.valueOf("dubbo://10.10.10.10:2181")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test-provider")
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
         
when(invocation.getObjectAttachment(Constants.REQUEST_SIGNATURE_KEY)).thenReturn("dubbo");
@@ -113,7 +117,7 @@ class ProviderAuthFilterTest {
         
when(invocation.getObjectAttachment(Constants.REQUEST_TIMESTAMP_KEY)).thenReturn(System.currentTimeMillis());
         when(invoker.getUrl()).thenReturn(url);
 
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         Result result = providerAuthFilter.invoke(invoker, invocation);
         assertTrue(result.hasException());
         assertTrue(result.getException() instanceof 
RpcAuthenticationException);
@@ -131,7 +135,8 @@ class ProviderAuthFilterTest {
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test-provider")
                 .addParameter(Constants.PARAMETER_SIGNATURE_ENABLE_KEY, true)
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
 
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
@@ -152,7 +157,7 @@ class ProviderAuthFilterTest {
         String sign = SignatureUtils.sign(originalParams, requestString, "sk");
         
when(invocation.getObjectAttachment(Constants.REQUEST_SIGNATURE_KEY)).thenReturn(sign);
 
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         Result result = providerAuthFilter.invoke(invoker, invocation);
         assertTrue(result.hasException());
         assertTrue(result.getException() instanceof 
RpcAuthenticationException);
@@ -168,7 +173,8 @@ class ProviderAuthFilterTest {
                 .addParameter(Constants.ACCESS_KEY_ID_KEY, "ak")
                 .addParameter(Constants.SECRET_ACCESS_KEY_KEY, "sk")
                 .addParameter(CommonConstants.APPLICATION_KEY, "test-provider")
-                .addParameter(Constants.SERVICE_AUTH, true);
+                .addParameter(Constants.AUTHENTICATOR_KEY, "accesskey")
+                .addParameter(Constants.AUTH_KEY, true);
         Invoker invoker = mock(Invoker.class);
         Invocation invocation = mock(RpcInvocation.class);
         when(invocation.getAttachment(Constants.AK_KEY)).thenReturn("ak");
@@ -186,7 +192,7 @@ class ProviderAuthFilterTest {
         String sign = SignatureUtils.sign(requestString, "sk");
         
when(invocation.getAttachment(Constants.REQUEST_SIGNATURE_KEY)).thenReturn(sign);
 
-        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(ApplicationModel.defaultModel());
+        ProviderAuthFilter providerAuthFilter = new 
ProviderAuthFilter(FrameworkModel.defaultModel());
         Result result = providerAuthFilter.invoke(invoker, invocation);
         assertNull(result);
     }
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
index b5c2b54ee4..2336b61d17 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/client/metadata/MetadataUtils.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.registry.client.metadata;
 
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.aot.NativeDetector;
+import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.common.extension.ExtensionLoader;
 import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
 import org.apache.dubbo.common.logger.LoggerFactory;
@@ -38,9 +39,11 @@ import org.apache.dubbo.registry.client.ServiceInstance;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.Protocol;
 import org.apache.dubbo.rpc.ProxyFactory;
+import org.apache.dubbo.rpc.cluster.filter.FilterChainBuilder;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 import org.apache.dubbo.rpc.model.ConsumerModel;
 import org.apache.dubbo.rpc.model.ModuleModel;
+import org.apache.dubbo.rpc.model.ScopeModelUtil;
 import org.apache.dubbo.rpc.model.ServiceDescriptor;
 import org.apache.dubbo.rpc.service.Destroyable;
 import org.apache.dubbo.rpc.stub.StubSuppliers;
@@ -51,9 +54,11 @@ import java.util.Map;
 import java.util.concurrent.ThreadLocalRandom;
 
 import static org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE;
+import static org.apache.dubbo.common.constants.CommonConstants.FILTER_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.NATIVE_STUB;
 import static org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE;
 import static 
org.apache.dubbo.common.constants.CommonConstants.PROXY_CLASS_REF;
+import static 
org.apache.dubbo.common.constants.CommonConstants.REFERENCE_FILTER_KEY;
 import static 
org.apache.dubbo.common.constants.CommonConstants.REMOTE_METADATA_STORAGE_TYPE;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
 import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_FAILED_CREATE_INSTANCE;
@@ -62,6 +67,7 @@ import static 
org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_CLUST
 import static org.apache.dubbo.metadata.util.MetadataServiceVersionUtils.V2;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.METADATA_SERVICE_URLS_PROPERTY_NAME;
 import static 
org.apache.dubbo.registry.client.metadata.ServiceInstanceMetadataUtils.METADATA_SERVICE_VERSION_NAME;
+import static org.apache.dubbo.rpc.Constants.AUTH_KEY;
 import static org.apache.dubbo.rpc.Constants.PROXY_KEY;
 
 public class MetadataUtils {
@@ -162,6 +168,9 @@ public class MetadataUtils {
         Protocol protocol = 
applicationModel.getExtensionLoader(Protocol.class).getExtension(url.getProtocol(),
 false);
 
         url = url.setServiceModel(consumerModel);
+        if (url.getParameter(AUTH_KEY, false)) {
+            url = url.addParameter(FILTER_KEY, "-default,consumersign");
+        }
 
         RemoteMetadataService remoteMetadataService;
         ProxyFactory proxyFactory =
@@ -169,11 +178,25 @@ public class MetadataUtils {
         if (useV2) {
             Invoker<MetadataServiceV2> invoker = 
protocol.refer(MetadataServiceV2.class, url);
 
+            if (url.getParameter(AUTH_KEY, false)) {
+                FilterChainBuilder filterChainBuilder = 
ScopeModelUtil.getExtensionLoader(
+                                FilterChainBuilder.class, url.getScopeModel())
+                        .getDefaultExtension();
+                invoker = filterChainBuilder.buildInvokerChain(invoker, 
REFERENCE_FILTER_KEY, CommonConstants.CONSUMER);
+            }
+
             remoteMetadataService =
                     new RemoteMetadataService(consumerModel, 
proxyFactory.getProxy(invoker), internalModel);
         } else {
             Invoker<MetadataService> invoker = 
protocol.refer(MetadataService.class, url);
 
+            if (url.getParameter(AUTH_KEY, false)) {
+                FilterChainBuilder filterChainBuilder = 
ScopeModelUtil.getExtensionLoader(
+                                FilterChainBuilder.class, url.getScopeModel())
+                        .getDefaultExtension();
+                invoker = filterChainBuilder.buildInvokerChain(invoker, 
REFERENCE_FILTER_KEY, CommonConstants.CONSUMER);
+            }
+
             remoteMetadataService =
                     new RemoteMetadataService(consumerModel, 
proxyFactory.getProxy(invoker), internalModel);
         }
diff --git 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
index f4d0578375..17ae1800cd 100644
--- 
a/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
+++ 
b/dubbo-registry/dubbo-registry-api/src/main/java/org/apache/dubbo/registry/integration/RegistryProtocol.java
@@ -90,12 +90,14 @@ import static 
org.apache.dubbo.common.constants.CommonConstants.IPV6_KEY;
 import static 
org.apache.dubbo.common.constants.CommonConstants.LOADBALANCE_KEY;
 import static 
org.apache.dubbo.common.constants.CommonConstants.MERGEABLE_CLUSTER_NAME;
 import static 
org.apache.dubbo.common.constants.CommonConstants.PACKABLE_METHOD_FACTORY_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.PASSWORD_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.PATH_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.PROTOCOL_KEY;
 import static 
org.apache.dubbo.common.constants.CommonConstants.REGISTRY_PROTOCOL_LISTENER_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.SIDE_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
+import static org.apache.dubbo.common.constants.CommonConstants.USERNAME_KEY;
 import static org.apache.dubbo.common.constants.CommonConstants.VERSION_KEY;
 import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.INTERNAL_ERROR;
 import static 
org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNSUPPORTED_CATEGORY;
@@ -123,6 +125,8 @@ import static 
org.apache.dubbo.remoting.Constants.CONNECTIONS_KEY;
 import static org.apache.dubbo.remoting.Constants.EXCHANGER_KEY;
 import static org.apache.dubbo.remoting.Constants.PREFER_SERIALIZATION_KEY;
 import static org.apache.dubbo.remoting.Constants.SERIALIZATION_KEY;
+import static org.apache.dubbo.rpc.Constants.AUTHENTICATOR_KEY;
+import static org.apache.dubbo.rpc.Constants.AUTH_KEY;
 import static org.apache.dubbo.rpc.Constants.DEPRECATED_KEY;
 import static org.apache.dubbo.rpc.Constants.GENERIC_KEY;
 import static org.apache.dubbo.rpc.Constants.MOCK_KEY;
@@ -139,10 +143,32 @@ import static 
org.apache.dubbo.rpc.model.ScopeModelUtil.getApplicationModel;
  */
 public class RegistryProtocol implements Protocol, ScopeModelAware {
     public static final String[] DEFAULT_REGISTER_PROVIDER_KEYS = {
-        APPLICATION_KEY, CODEC_KEY, EXCHANGER_KEY, SERIALIZATION_KEY, 
PREFER_SERIALIZATION_KEY, CLUSTER_KEY,
-                CONNECTIONS_KEY, DEPRECATED_KEY,
-        GROUP_KEY, LOADBALANCE_KEY, MOCK_KEY, PATH_KEY, TIMEOUT_KEY, 
TOKEN_KEY, VERSION_KEY, WARMUP_KEY,
-        WEIGHT_KEY, DUBBO_VERSION_KEY, RELEASE_KEY, SIDE_KEY, IPV6_KEY, 
PACKABLE_METHOD_FACTORY_KEY
+        APPLICATION_KEY,
+        CODEC_KEY,
+        EXCHANGER_KEY,
+        SERIALIZATION_KEY,
+        PREFER_SERIALIZATION_KEY,
+        CLUSTER_KEY,
+        CONNECTIONS_KEY,
+        DEPRECATED_KEY,
+        GROUP_KEY,
+        LOADBALANCE_KEY,
+        MOCK_KEY,
+        PATH_KEY,
+        TIMEOUT_KEY,
+        TOKEN_KEY,
+        VERSION_KEY,
+        WARMUP_KEY,
+        WEIGHT_KEY,
+        DUBBO_VERSION_KEY,
+        RELEASE_KEY,
+        SIDE_KEY,
+        IPV6_KEY,
+        PACKABLE_METHOD_FACTORY_KEY,
+        AUTH_KEY,
+        AUTHENTICATOR_KEY,
+        USERNAME_KEY,
+        PASSWORD_KEY
     };
 
     public static final String[] DEFAULT_REGISTER_CONSUMER_KEYS = {
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Constants.java 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Constants.java
index 9821dc93dd..3e34880187 100644
--- a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Constants.java
+++ b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Constants.java
@@ -74,6 +74,10 @@ public interface Constants {
 
     String TOKEN_KEY = "token";
 
+    String AUTH_KEY = "auth";
+
+    String AUTHENTICATOR_KEY = "authenticator";
+
     String INTERFACE = "interface";
 
     String INTERFACES = "interfaces";
@@ -103,7 +107,6 @@ public interface Constants {
     String H2_SETTINGS_IGNORE_1_0_0_KEY = "dubbo.rpc.tri.ignore-1.0.0-version";
     String H2_SETTINGS_RESOLVE_FALLBACK_TO_DEFAULT_KEY = 
"dubbo.rpc.tri.resolve-fallback-to-default";
     String H2_SETTINGS_BUILTIN_SERVICE_INIT = "dubbo.tri.builtin.service.init";
-    String H2_SETTINGS_PASS_THROUGH_STANDARD_HTTP_HEADERS = 
"dubbo.rpc.tri.pass-through-standard-http-headers";
 
     String H2_SETTINGS_JSON_FRAMEWORK_NAME = 
"dubbo.protocol.triple.rest.json-framework";
 
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
index 5a955a958d..21781951c7 100644
--- 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java
@@ -31,6 +31,7 @@ import org.apache.dubbo.rpc.RpcInvocation;
 import org.apache.dubbo.rpc.TimeoutCountDown;
 import org.apache.dubbo.rpc.model.ApplicationModel;
 import org.apache.dubbo.rpc.support.RpcUtils;
+import org.apache.dubbo.rpc.support.TrieTree;
 
 import java.util.HashMap;
 import java.util.HashSet;
@@ -69,23 +70,68 @@ public class ContextFilter implements Filter, 
Filter.Listener {
         supportedSelectors = 
selectorExtensionLoader.getSupportedExtensionInstances();
     }
 
-    private static final Set<String> UNLOADING_KEYS;
+    private static final TrieTree UNLOADING_KEYS;
 
     static {
-        UNLOADING_KEYS = new HashSet<>(16);
-        UNLOADING_KEYS.add(PATH_KEY);
-        UNLOADING_KEYS.add(INTERFACE_KEY);
-        UNLOADING_KEYS.add(GROUP_KEY);
-        UNLOADING_KEYS.add(VERSION_KEY);
-        UNLOADING_KEYS.add(DUBBO_VERSION_KEY);
-        UNLOADING_KEYS.add(TOKEN_KEY);
-        UNLOADING_KEYS.add(TIMEOUT_KEY);
-        UNLOADING_KEYS.add(TIMEOUT_ATTACHMENT_KEY);
+        Set<String> keySet = new HashSet<>();
+        keySet.add(PATH_KEY);
+        keySet.add(INTERFACE_KEY);
+        keySet.add(GROUP_KEY);
+        keySet.add(VERSION_KEY);
+        keySet.add(DUBBO_VERSION_KEY);
+        keySet.add(TOKEN_KEY);
+        keySet.add(TIMEOUT_KEY);
+        keySet.add(TIMEOUT_ATTACHMENT_KEY);
 
         // Remove async property to avoid being passed to the following invoke 
chain.
-        UNLOADING_KEYS.add(ASYNC_KEY);
-        UNLOADING_KEYS.add(TAG_KEY);
-        UNLOADING_KEYS.add(FORCE_USE_TAG);
+        keySet.add(ASYNC_KEY);
+        keySet.add(TAG_KEY);
+        keySet.add(FORCE_USE_TAG);
+
+        // Remove HTTP headers to avoid being passed to the following invoke 
chain.
+        keySet.add("accept");
+        keySet.add("accept-charset");
+        keySet.add("accept-datetime");
+        keySet.add("accept-encoding");
+        keySet.add("accept-language");
+        keySet.add("access-control-request-headers");
+        keySet.add("access-control-request-method");
+        keySet.add("authorization");
+        keySet.add("cache-control");
+        keySet.add("connection");
+        keySet.add("content-length");
+        keySet.add("content-md5");
+        keySet.add("content-type");
+        keySet.add("cookie");
+        keySet.add("date");
+        keySet.add("dnt");
+        keySet.add("expect");
+        keySet.add("forwarded");
+        keySet.add("from");
+        keySet.add("host");
+        keySet.add("http2-settings");
+        keySet.add("if-match");
+        keySet.add("if-modified-since");
+        keySet.add("if-none-match");
+        keySet.add("if-range");
+        keySet.add("if-unmodified-since");
+        keySet.add("max-forwards");
+        keySet.add("origin");
+        keySet.add("pragma");
+        keySet.add("proxy-authorization");
+        keySet.add("range");
+        keySet.add("referer");
+        keySet.add("sec-fetch-dest");
+        keySet.add("sec-fetch-mode");
+        keySet.add("sec-fetch-site");
+        keySet.add("sec-fetch-user");
+        keySet.add("te");
+        keySet.add("trailer");
+        keySet.add("upgrade");
+        keySet.add("upgrade-insecure-requests");
+        keySet.add("user-agent");
+
+        UNLOADING_KEYS = new TrieTree(keySet);
     }
 
     @Override
@@ -95,7 +141,7 @@ public class ContextFilter implements Filter, 
Filter.Listener {
             Map<String, Object> newAttach = new HashMap<>(attachments.size());
             for (Map.Entry<String, Object> entry : attachments.entrySet()) {
                 String key = entry.getKey();
-                if (!UNLOADING_KEYS.contains(key)) {
+                if (!UNLOADING_KEYS.search(key)) {
                     newAttach.put(key, entry.getValue());
                 }
             }
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/TrieTree.java
 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/TrieTree.java
new file mode 100644
index 0000000000..9623137f33
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/support/TrieTree.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.support;
+
+import java.util.Set;
+
+class TrieNode {
+    TrieNode[] children;
+    boolean isEndOfWord = false;
+
+    // Constructor: Initializes children array
+    public TrieNode() {
+        this.children = new TrieNode[29]; // 0-25: 'a' - 'z', 26: '-', 27: 
'_', 28: '.'
+    }
+}
+
+public class TrieTree {
+    private final TrieNode root;
+
+    // Constructor: Initializes the Trie and inserts all words from the given 
set
+    public TrieTree(Set<String> words) {
+        root = new TrieNode();
+        for (String word : words) {
+            insert(word);
+        }
+    }
+
+    // Inserts a word into the Trie, case-insensitive
+    private void insert(String word) {
+        TrieNode node = root;
+        for (char ch : word.toCharArray()) {
+            int index = getCharIndex(ch);
+            if (index == -1) {
+                return; // Invalid character, skip this word
+            }
+
+            if (node.children[index] == null) {
+                node.children[index] = new TrieNode();
+            }
+            node = node.children[index];
+        }
+        node.isEndOfWord = true;
+    }
+
+    // Checks if a word exists in the Trie, case-insensitive
+    public boolean search(String word) {
+        TrieNode node = root;
+        for (char ch : word.toCharArray()) {
+            int index = getCharIndex(ch);
+            if (index == -1 || node.children[index] == null) {
+                return false; // Invalid character or node doesn't exist
+            }
+            node = node.children[index];
+        }
+        return node.isEndOfWord;
+    }
+
+    // Maps the character to the array index, handling case-insensitivity
+    // 'a-z' -> 0-25, '-' -> 26, '_' -> 27, '.' -> 28
+    // Returns -1 if the character is invalid
+    private int getCharIndex(char ch) {
+        // Convert uppercase to lowercase within this function
+        if (ch >= 'A' && ch <= 'Z') {
+            ch = (char) (ch + 32); // Convert 'A'-'Z' to 'a'-'z'
+        }
+        if (ch >= 'a' && ch <= 'z') {
+            return ch - 'a'; // 'a' -> 0, 'b' -> 1, ..., 'z' -> 25
+        } else if (ch == '-') {
+            return 26;
+        } else if (ch == '_') {
+            return 27;
+        } else if (ch == '.') {
+            return 28;
+        } else {
+            return -1; // Invalid character
+        }
+    }
+}
diff --git 
a/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/TrieTreeTest.java
 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/TrieTreeTest.java
new file mode 100644
index 0000000000..5c51877c60
--- /dev/null
+++ 
b/dubbo-rpc/dubbo-rpc-api/src/test/java/org/apache/dubbo/rpc/support/TrieTreeTest.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.rpc.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class TrieTreeTest {
+
+    private TrieTree trie;
+
+    @BeforeEach
+    void setUp() {
+        // Initialize the set of words before each test
+        Set<String> words = new HashSet<>();
+        words.add("apple");
+        words.add("App-le");
+        words.add("apply");
+        words.add("app_le.juice");
+        words.add("app-LE_juice");
+
+        // Initialize TrieTree
+        trie = new TrieTree(words);
+    }
+
+    @Test
+    void testSearchValidWords() {
+        // Test valid words
+        assertTrue(trie.search("apple"));
+        assertTrue(trie.search("App-LE"));
+        assertTrue(trie.search("apply"));
+        assertTrue(trie.search("app_le.juice"));
+        assertTrue(trie.search("app-LE_juice"));
+    }
+
+    @Test
+    void testSearchInvalidWords() {
+        // Test invalid words
+        assertFalse(trie.search("app"));
+        // Invalid character test
+        assertFalse(trie.search("app%le"));
+    }
+}
diff --git 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/TriRpcStatus.java
 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/TriRpcStatus.java
index ef5d4893a8..df45b6d5e2 100644
--- 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/TriRpcStatus.java
+++ 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/TriRpcStatus.java
@@ -26,6 +26,7 @@ import io.netty.handler.codec.http.HttpResponseStatus;
 import io.netty.handler.codec.http.QueryStringDecoder;
 import io.netty.handler.codec.http.QueryStringEncoder;
 
+import static org.apache.dubbo.rpc.RpcException.AUTHORIZATION_EXCEPTION;
 import static org.apache.dubbo.rpc.RpcException.FORBIDDEN_EXCEPTION;
 import static org.apache.dubbo.rpc.RpcException.LIMIT_EXCEEDED_EXCEPTION;
 import static org.apache.dubbo.rpc.RpcException.METHOD_NOT_FOUND;
@@ -126,6 +127,9 @@ public class TriRpcStatus implements Serializable {
             case FORBIDDEN_EXCEPTION:
                 code = Code.PERMISSION_DENIED;
                 break;
+            case AUTHORIZATION_EXCEPTION:
+                code = Code.UNAUTHENTICATED;
+                break;
             case LIMIT_EXCEEDED_EXCEPTION:
             case NETWORK_EXCEPTION:
                 code = Code.UNAVAILABLE;
diff --git 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHeaderEnum.java
 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHeaderEnum.java
index 0644403aa1..886ade0f43 100644
--- 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHeaderEnum.java
+++ 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleHeaderEnum.java
@@ -67,67 +67,6 @@ public enum TripleHeaderEnum {
             RestConstants.HEADER_SERVICE_GROUP
         };
         Collections.addAll(excludeAttachmentsSet, internalHttpHeaders);
-
-        String[] excludeStandardHttpHeaders;
-        if (TripleProtocol.PASS_THROUGH_STANDARD_HTTP_HEADERS) {
-            excludeStandardHttpHeaders = new String[] {
-                "accept",
-                "accept-charset",
-                "accept-encoding",
-                "accept-language",
-                "cache-control",
-                "connection",
-                "content-length",
-                "content-md5",
-                "content-type",
-                "host"
-            };
-        } else {
-            excludeStandardHttpHeaders = new String[] {
-                "accept",
-                "accept-charset",
-                "accept-datetime",
-                "accept-encoding",
-                "accept-language",
-                "access-control-request-headers",
-                "access-control-request-method",
-                "authorization",
-                "cache-control",
-                "connection",
-                "content-length",
-                "content-md5",
-                "content-type",
-                "cookie",
-                "date",
-                "dnt",
-                "expect",
-                "forwarded",
-                "from",
-                "host",
-                "http2-settings",
-                "if-match",
-                "if-modified-since",
-                "if-none-match",
-                "if-range",
-                "if-unmodified-since",
-                "max-forwards",
-                "origin",
-                "pragma",
-                "proxy-authorization",
-                "range",
-                "referer",
-                "sec-fetch-dest",
-                "sec-fetch-mode",
-                "sec-fetch-site",
-                "sec-fetch-user",
-                "te",
-                "trailer",
-                "upgrade",
-                "upgrade-insecure-requests"
-            };
-        }
-
-        Collections.addAll(excludeAttachmentsSet, excludeStandardHttpHeaders);
     }
 
     private final String name;
diff --git 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocol.java
 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocol.java
index e3ac4aa0ee..2df0c748d5 100644
--- 
a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocol.java
+++ 
b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/TripleProtocol.java
@@ -50,7 +50,6 @@ import static 
org.apache.dubbo.common.constants.CommonConstants.THREAD_NAME_KEY;
 import static org.apache.dubbo.config.Constants.CLIENT_THREAD_POOL_NAME;
 import static org.apache.dubbo.config.Constants.SERVER_THREAD_POOL_NAME;
 import static org.apache.dubbo.rpc.Constants.H2_SETTINGS_IGNORE_1_0_0_KEY;
-import static 
org.apache.dubbo.rpc.Constants.H2_SETTINGS_PASS_THROUGH_STANDARD_HTTP_HEADERS;
 import static 
org.apache.dubbo.rpc.Constants.H2_SETTINGS_RESOLVE_FALLBACK_TO_DEFAULT_KEY;
 import static 
org.apache.dubbo.rpc.Constants.H2_SETTINGS_SUPPORT_NO_LOWER_HEADER_KEY;
 import static org.apache.dubbo.rpc.Constants.H2_SETTINGS_VERBOSE_ENABLED;
@@ -65,7 +64,6 @@ public class TripleProtocol extends AbstractProtocol {
     public static boolean CONVERT_NO_LOWER_HEADER = false;
     public static boolean IGNORE_1_0_0_VERSION = false;
     public static boolean RESOLVE_FALLBACK_TO_DEFAULT = true;
-    public static boolean PASS_THROUGH_STANDARD_HTTP_HEADERS = false;
     public static boolean VERBOSE_ENABLED = false;
 
     public TripleProtocol(FrameworkModel frameworkModel) {
@@ -80,7 +78,6 @@ public class TripleProtocol extends AbstractProtocol {
         CONVERT_NO_LOWER_HEADER = 
conf.getBoolean(H2_SETTINGS_SUPPORT_NO_LOWER_HEADER_KEY, true);
         IGNORE_1_0_0_VERSION = conf.getBoolean(H2_SETTINGS_IGNORE_1_0_0_KEY, 
false);
         RESOLVE_FALLBACK_TO_DEFAULT = 
conf.getBoolean(H2_SETTINGS_RESOLVE_FALLBACK_TO_DEFAULT_KEY, true);
-        PASS_THROUGH_STANDARD_HTTP_HEADERS = 
conf.getBoolean(H2_SETTINGS_PASS_THROUGH_STANDARD_HTTP_HEADERS, false);
 
         // init global settings
         Configuration globalConf = 
ConfigurationUtils.getGlobalConfiguration(frameworkModel.defaultApplication());

Reply via email to