Skip to content

Commit

Permalink
use originalAuthMethod on originalAuthChecker (#6870)
Browse files Browse the repository at this point in the history
Fixes #6873

Use originalAuthMethod on originalAuthProvider check.
(cherry picked from commit 8381371)
  • Loading branch information
KannarFr authored and jiazhai committed May 12, 2020
1 parent 7a71328 commit 450cc15
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,23 @@ protected void handleConnect(CommandConnect connect) {
// 2. we require to validate the original credentials
// 3. no credentials were passed
if (connect.hasOriginalPrincipal() && service.getPulsar().getConfig().isAuthenticateOriginalAuthData()) {
// init authentication
String originalAuthMethod;
if (connect.hasOriginalAuthMethod()) {
originalAuthMethod = connect.getOriginalAuthMethod();
} else {
originalAuthMethod = "none";
}

AuthenticationProvider originalAuthenticationProvider = getBrokerService()
.getAuthenticationService()
.getAuthenticationProvider(authMethod);
.getAuthenticationProvider(originalAuthMethod);

if (originalAuthenticationProvider == null) {
throw new AuthenticationException(String.format("Can't find AuthenticationProvider for original role" +
" using auth method [%s] is not available", originalAuthMethod));
}

originalAuthState = originalAuthenticationProvider.newAuthState(
AuthData.of(connect.getOriginalAuthData().getBytes()),
remoteAddress,
Expand Down

0 comments on commit 450cc15

Please sign in to comment.