Skip to content

Commit

Permalink
Revert AuthenticationProviderMTls
Browse files Browse the repository at this point in the history
  • Loading branch information
coderzc committed Nov 22, 2024
1 parent 367595c commit ace5d00
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package io.streamnative.pulsar.handlers.mqtt.proxy.authentication.mtls;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Joiner;
Expand Down Expand Up @@ -213,16 +214,22 @@ public String authenticate(AuthenticationDataSource authData) throws Authenticat
// parse SHA1
params.put(ExpressionCompiler.SHA1, parseSHA1FingerPrint(certificate));

String principal = matchPool(params);
if (principal.isEmpty()) {
String poolName = matchPool(params);
if (poolName.isEmpty()) {
errorCode = ErrorCode.NO_MATCH_POOL;
throw new AuthenticationException("No matched identity pool from the client certificate");
}
AuthRequest authRequest = new AuthRequest(poolName, params);
String authRequestJson = objectMapper.writeValueAsString(authRequest);
AuthenticationMetrics.authenticateSuccess(this.getClass().getSimpleName(), this.getAuthMethodName());
return principal;
return authRequestJson;
} catch (AuthenticationException e) {
this.incrementFailureMetric(errorCode);
throw e;
} catch (JsonProcessingException e) {
log.error("Failed to serialize the auth request", e);
this.incrementFailureMetric(errorCode);
throw new AuthenticationException(e.getMessage());
}
}

Expand Down

0 comments on commit ace5d00

Please sign in to comment.