Skip to content

Commit 8fb9735

Browse files
committed
feat: received service name. default is fluss.
1 parent e887ea6 commit 8fb9735

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

fluss-common/src/main/java/org/apache/fluss/config/ConfigOptions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,14 @@ public class ConfigOptions {
12341234
+ "This is used when the client connects to the Fluss cluster with SASL authentication enabled. "
12351235
+ "If not provided, the password will be read from the JAAS configuration string specified by `client.security.sasl.jaas.config`.");
12361236

1237+
public static final ConfigOption<String> CLIENT_KERBEROS_SERVICE_NAME =
1238+
key("client.security.kerberos.service.name")
1239+
.stringType()
1240+
.defaultValue("fluss")
1241+
.withDescription(
1242+
"The Kerberos principal name that the server runs as. This can be defined either in "
1243+
+ "Fluss's JAAS config or in Fluss's config.");
1244+
12371245
// ------------------------------------------------------------------------
12381246
// ConfigOptions for Fluss Table
12391247
// ------------------------------------------------------------------------

fluss-common/src/main/java/org/apache/fluss/security/auth/sasl/authenticator/SaslClientAuthenticator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.security.PrivilegedExceptionAction;
3333
import java.util.Map;
3434

35+
import static org.apache.fluss.config.ConfigOptions.CLIENT_KERBEROS_SERVICE_NAME;
3536
import static org.apache.fluss.config.ConfigOptions.CLIENT_SASL_JAAS_CONFIG;
3637
import static org.apache.fluss.config.ConfigOptions.CLIENT_SASL_JAAS_PASSWORD;
3738
import static org.apache.fluss.config.ConfigOptions.CLIENT_SASL_JAAS_USERNAME;
@@ -45,12 +46,14 @@ public class SaslClientAuthenticator implements ClientAuthenticator {
4546
private final String mechanism;
4647
private final Map<String, String> pros;
4748
private final String jaasConfig;
49+
private final String serviceName;
4850

4951
private SaslClient saslClient;
5052
private LoginManager loginManager;
5153

5254
public SaslClientAuthenticator(Configuration configuration) {
5355
this.mechanism = configuration.get(CLIENT_SASL_MECHANISM).toUpperCase();
56+
this.serviceName = configuration.get(CLIENT_KERBEROS_SERVICE_NAME);
5457
String jaasConfigStr = configuration.getString(CLIENT_SASL_JAAS_CONFIG);
5558
if (jaasConfigStr == null && mechanism.equals(PlainSaslServer.PLAIN_MECHANISM)) {
5659
String username = configuration.get(CLIENT_SASL_JAAS_USERNAME);
@@ -109,7 +112,7 @@ public void initialize(AuthenticateContext context) throws AuthenticationExcepti
109112
}
110113

111114
try {
112-
saslClient = createSaslClient(mechanism, hostAddress, pros, loginManager);
115+
saslClient = createSaslClient(mechanism, hostAddress, pros, loginManager, serviceName);
113116
} catch (Exception e) {
114117
throw new AuthenticationException("Failed to create SASL client", e);
115118
}

fluss-common/src/main/java/org/apache/fluss/security/auth/sasl/jaas/SaslServerFactory.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,18 @@ public static SaslServer createSaslServer(
9191
}
9292

9393
public static SaslClient createSaslClient(
94-
String mechanism, String hostAddress, Map<String, ?> props, LoginManager loginManager)
94+
String mechanism,
95+
String hostAddress,
96+
Map<String, ?> props,
97+
LoginManager loginManager,
98+
String serviceName)
9599
throws PrivilegedActionException {
96100

97101
return Subject.doAs(
98102
loginManager.subject(),
99103
(PrivilegedExceptionAction<SaslClient>)
100104
() -> {
101105
String[] mechs = {mechanism};
102-
// The serviceName here is the name of the service we are connecting to.
103-
// It is NOT the name of the client principal.
104-
String serviceName = "fluss";
105106
LOG.debug(
106107
"Creating SaslClient: service={};mechs={}",
107108
serviceName,

0 commit comments

Comments
 (0)