Skip to content

Commit 563338c

Browse files
authored
MINOR: Refactor on DelegationTokenManager follow up with KAFKA-18711 (#20579)
Follow-up PR of KAFKA-18711. The motivation and reason for this change are outlined in [1]. [1] - #20475 (comment) Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
1 parent ac63ce9 commit 563338c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

core/src/main/scala/kafka/server/KafkaApis.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ import org.apache.kafka.security.DelegationTokenManager
6464
import org.apache.kafka.server.{ApiVersionManager, ClientMetricsManager, ProcessRole}
6565
import org.apache.kafka.server.authorizer._
6666
import org.apache.kafka.server.common.{GroupVersion, RequestLocal, ShareVersion, StreamsVersion, TransactionVersion}
67-
import org.apache.kafka.server.config.DelegationTokenManagerConfigs
6867
import org.apache.kafka.server.share.context.ShareFetchContext
6968
import org.apache.kafka.server.share.{ErroneousAndValidPartitionData, SharePartitionKey}
7069
import org.apache.kafka.server.share.acknowledge.ShareAcknowledgementBatch
@@ -2314,7 +2313,7 @@ class KafkaApis(val requestChannel: RequestChannel,
23142313

23152314
if (!allowTokenRequests(request))
23162315
sendResponseCallback(Errors.DELEGATION_TOKEN_REQUEST_NOT_ALLOWED, Collections.emptyList)
2317-
else if (!new DelegationTokenManagerConfigs(config).tokenAuthEnabled)
2316+
else if (!tokenManager.isEnabled)
23182317
sendResponseCallback(Errors.DELEGATION_TOKEN_AUTH_DISABLED, Collections.emptyList)
23192318
else {
23202319
val requestPrincipal = request.context.principal

server-common/src/main/java/org/apache/kafka/security/DelegationTokenManager.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ public List<DelegationToken> getTokens(Predicate<TokenInformation> filterToken)
104104
.toList();
105105
}
106106

107+
public boolean isEnabled() {
108+
return secretKey != null;
109+
}
110+
107111
public static boolean filterToken(
108112
KafkaPrincipal requesterPrincipal,
109113
Optional<List<KafkaPrincipal>> owners,

0 commit comments

Comments
 (0)