merlimat commented on a change in pull request #6799:
URL: https://github.com/apache/pulsar/pull/6799#discussion_r626169169



##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/authentication/AuthenticationService.java
##########
@@ -99,18 +99,38 @@ public String authenticate(AuthenticationDataSource 
authData, String authMethodN
     }
 
     public String authenticateHttpRequest(HttpServletRequest request) throws 
AuthenticationException {
-        // Try to validate with any configured provider
         AuthenticationException authenticationException = null;
         AuthenticationDataSource authData = new 
AuthenticationDataHttps(request);
-        for (AuthenticationProvider provider : providers.values()) {
+        String authMethodName = request.getHeader("X-Pulsar-Auth-Method-Name");
+
+        if (authMethodName != null) {
+            AuthenticationProvider providerToUse = providers
+                    .values()
+                    .parallelStream()
+                    .filter(provider -> 
provider.getAuthMethodName().equals(authMethodName))
+                    .findAny()
+                    .orElseThrow(() -> new 
AuthenticationException(String.format("Unsupported header 
X-Pulsar-Auth-Method-Name [%s].", authMethodName)));

Review comment:
       ```suggestion
               AuthenticationProvider providerToUse = 
providers.get(authMethodName);
               if (providerToUse == null) {
                   throw new AuthenticationException(
                       String.format("Unsupported authentication method: 
[%s].", authMethodName);
               }
   ```




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to