Skip to content

Commit

Permalink
Add support for Hive delegation token renewer principal configuration.
Browse files Browse the repository at this point in the history
This patch introduces a new configuration option, security.delegation.tokens.hive.renewer, that allows specifying the principal under which Hive delegation tokens will be renewed.
  • Loading branch information
Asmoday committed Sep 9, 2024
1 parent 2b000a3 commit d39d38c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package org.apache.flink.table.security.token;

import org.apache.commons.lang3.StringUtils;

import org.apache.flink.annotation.Internal;
import org.apache.flink.annotation.VisibleForTesting;
import org.apache.flink.configuration.Configuration;
Expand All @@ -31,6 +29,7 @@
import org.apache.flink.util.FlinkRuntimeException;
import org.apache.flink.util.Preconditions;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.ql.metadata.Hive;
import org.apache.hadoop.security.Credentials;
Expand Down Expand Up @@ -70,8 +69,8 @@ public String serviceName() {
public void init(Configuration configuration) throws Exception {
hiveConf = getHiveConfiguration(configuration);
kerberosLoginProvider = new KerberosLoginProvider(configuration);
hiveTokenRenewerPrincipal = configuration
.get(SecurityOptions.DELEGATION_TOKENS_HIVE_RENEWER, "");
hiveTokenRenewerPrincipal =
configuration.get(SecurityOptions.DELEGATION_TOKENS_HIVE_RENEWER, "");
}

private org.apache.hadoop.conf.Configuration getHiveConfiguration(Configuration conf) {
Expand Down Expand Up @@ -143,11 +142,11 @@ public ObtainedDelegationTokens obtainDelegationTokens() throws Exception {
try {
LOG.info("Obtaining Kerberos security token for HiveServer2");

String principal = !StringUtils.isEmpty(hiveTokenRenewerPrincipal) ?
hiveTokenRenewerPrincipal :
hiveConf.getTrimmed(
"hive.metastore.kerberos.principal",
"");
String principal =
!StringUtils.isEmpty(hiveTokenRenewerPrincipal)
? hiveTokenRenewerPrincipal
: hiveConf.getTrimmed(
"hive.metastore.kerberos.principal", "");

String tokenStr =
hive.getDelegationToken(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ public class SecurityOptions {
key("security.delegation.tokens.hive.renewer")
.stringType()
.noDefaultValue()
.withDescription("Specifies the principal under which the delegation tokens "
+ "for Hive will be renewed.");
.withDescription(
"Specifies the principal under which the delegation tokens "
+ "for Hive will be renewed.");

/**
* Returns a view over the given configuration via which options can be set/retrieved for the
Expand Down

0 comments on commit d39d38c

Please sign in to comment.