public class FileBasedPlainSaslAuthenticator
extends java.lang.Object
Since we have to use JAAS, the JAAS config just points to the YAML config file.
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
AUTHENTICATION_FAILED_MSG
Visible for testing
|
protected static java.lang.String |
NOT_PROVIDED_MSG |
Constructor and Description |
---|
FileBasedPlainSaslAuthenticator() |
Modifier and Type | Method and Description |
---|---|
MultiTenantPrincipal |
authenticate(java.lang.String username,
java.lang.String password,
java.util.Optional<javax.net.ssl.SNIHostName> sniHostName)
Authenticate user by checking username, password and cluster id.
|
java.util.Optional<java.lang.String> |
clusterId(java.lang.String username)
return cluster Id for the given username/APIKey
|
void |
initialize(java.util.List<javax.security.auth.login.AppConfigurationEntry> jaasContextEntries) |
protected static final java.lang.String AUTHENTICATION_FAILED_MSG
protected static final java.lang.String NOT_PROVIDED_MSG
public void initialize(java.util.List<javax.security.auth.login.AppConfigurationEntry> jaasContextEntries)
public MultiTenantPrincipal authenticate(java.lang.String username, java.lang.String password, java.util.Optional<javax.net.ssl.SNIHostName> sniHostName) throws javax.security.sasl.SaslException, org.apache.kafka.common.errors.SaslAuthenticationException
username
- usernamepassword
- passwordsniHostName
- SNI broker hostname. We store host name in SNI to route to relevant broker.MultiTenantPrincipal
containing authorization id and tenantorg.apache.kafka.common.errors.SaslAuthenticationException
- if authentication fails.
Note that the error string in the SaslAuthenticationException
is returned to the client so do not leak information in it.javax.security.sasl.SaslException
- if any unexpected errors are encounteredpublic java.util.Optional<java.lang.String> clusterId(java.lang.String username) throws javax.security.sasl.SaslException
javax.security.sasl.SaslException