gaoran10 commented on a change in pull request #14044:
URL: https://github.com/apache/pulsar/pull/14044#discussion_r803244752



##########
File path: 
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/web/AuthenticationFilter.java
##########
@@ -76,8 +77,15 @@ public void doFilter(ServletRequest request, ServletResponse 
response, FilterCha
                 // not sasl type, return role directly.
                 String role = 
authenticationService.authenticateHttpRequest((HttpServletRequest) request);
                 request.setAttribute(AuthenticatedRoleAttributeName, role);
-                request.setAttribute(AuthenticatedDataAttributeName,
-                    new AuthenticationDataHttps((HttpServletRequest) request));
+                String authMethodName = 
httpRequest.getHeader("X-Pulsar-Auth-Method-Name");
+                if (authMethodName != null && 
authenticationService.getAuthenticationProvider(authMethodName) != null) {
+                    AuthenticationState authenticationState = 
authenticationService
+                            
.getAuthenticationProvider(authMethodName).newHttpAuthState(httpRequest);
+                    request.setAttribute(AuthenticatedDataAttributeName, 
authenticationState.getAuthDataSource());

Review comment:
       Yes, but it seems that the implementation of `AuthenticationDataSource` 
here will always be `AuthenticationDataHttps`. Could we change here to 
`request.setAttribute(AuthenticatedDataAttributeName, (AuthenticationDataHttps) 
authenticationState.getAuthDataSource());`? Because the method 
`getAuthenticationProvider(authMethodName).newHttpAuthState(httpRequest)` has 
only one implementation. We could change the 
`FunctionApiResource#clientAuthData` in the future if there are more 
implementations.




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


Reply via email to