Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use originalAuthMethod on originalAuthChecker #6870

Merged
merged 3 commits into from
May 9, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,26 @@ 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 if (connect.hasOriginalAuthMethod()) {
// Legacy client is passing enum
originalAuthMethod = connect.getOriginalAuthMethod().substring(10).toLowerCase();
} 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