Skip to content

HBASE-26212 Expose configuration to enable/disable AuthUtil #3619

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public void newDead(ServerName sn) {

private void spawnRenewalChore(final UserGroupInformation user) {
ChoreService service = getChoreService();
service.scheduleChore(AuthUtil.getAuthRenewalChore(user));
service.scheduleChore(AuthUtil.getAuthRenewalChore(user, conf));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ replicaSelectorClass, META_TABLE_NAME, getChoreService(), () -> {

private void spawnRenewalChore(final UserGroupInformation user) {
ChoreService service = getChoreService();
service.scheduleChore(AuthUtil.getAuthRenewalChore(user));
service.scheduleChore(AuthUtil.getAuthRenewalChore(user, conf));
}

/**
Expand Down
22 changes: 19 additions & 3 deletions hbase-common/src/main/java/org/apache/hadoop/hbase/AuthUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public final class AuthUtil {
/** Client principal */
public static final String HBASE_CLIENT_KERBEROS_PRINCIPAL = "hbase.client.keytab.principal";

/** Configuration to automatically try to renew keytab-based logins */
public static final String HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_KEY = "hbase.client.keytab.automatic.renewal";
public static final boolean HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_DEFAULT = true;

private AuthUtil() {
super();
}
Expand Down Expand Up @@ -189,8 +193,8 @@ private static User loginClientAsService(Configuration conf) throws IOException
* @return a ScheduledChore for renewals.
*/
@InterfaceAudience.Private
public static ScheduledChore getAuthRenewalChore(final UserGroupInformation user) {
if (!user.hasKerberosCredentials()) {
public static ScheduledChore getAuthRenewalChore(final UserGroupInformation user, Configuration conf) {
if (!user.hasKerberosCredentials() || !isAuthRenewalChoreEnabled(conf)) {
return null;
}

Expand Down Expand Up @@ -221,8 +225,11 @@ protected void chore() {
*/
@Deprecated
public static ScheduledChore getAuthChore(Configuration conf) throws IOException {
if (!isAuthRenewalChoreEnabled(conf)) {
return null;
}
User user = loginClientAsService(conf);
return getAuthRenewalChore(user.getUGI());
return getAuthRenewalChore(user.getUGI(), conf);
}

private static Stoppable createDummyStoppable() {
Expand Down Expand Up @@ -271,4 +278,13 @@ public static String getGroupName(String aclKey) {
public static String toGroupEntry(String name) {
return GROUP_PREFIX + name;
}

/**
* Returns true if the chore to automatically renew Kerberos tickets (from
* keytabs) should be started. The default is true.
*/
static boolean isAuthRenewalChoreEnabled(Configuration conf) {
return conf.getBoolean(HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_KEY,
HBASE_CLIENT_AUTOMATIC_KEYTAB_RENEWAL_DEFAULT);
}
}