World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#3658] docs(hadoop-catalog): Add document about user authentication for Hadoop catalog (#3659)
Qi Yu4a3ac04f395c
diff --git a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.javaindex d65da06546..283b03c3b3 100644--- a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java+++ b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/HadoopCatalogOperations.java@@ -45,6 +45,7 @@ import java.io.IOException;import java.time.Instant;import java.util.Collections;import java.util.List;+import java.util.Locale;import java.util.Map;import java.util.Optional;import java.util.stream.Collectors;@@ -53,6 +54,7 @@ import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;import org.apache.hadoop.security.UserGroupInformation;+import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -123,18 +125,19 @@ public class HadoopCatalogOperations implements CatalogOperations, SupportsSchemprivate void initAuthentication(Map<String, String> conf, Configuration hadoopConf) {AuthenticationConfig config = new AuthenticationConfig(conf);- boolean enableAuth = config.isEnableAuth();String authType = config.getAuthType();- if (enableAuth && StringUtils.equalsIgnoreCase(authType, "kerberos")) {- hadoopConf.set(HADOOP_SECURITY_AUTHENTICATION, "kerberos");+ if (StringUtils.equalsIgnoreCase(authType, AuthenticationMethod.KERBEROS.name())) {+ hadoopConf.set(+ HADOOP_SECURITY_AUTHENTICATION,+ AuthenticationMethod.KERBEROS.name().toLowerCase(Locale.ROOT));UserGroupInformation.setConfiguration(hadoopConf);try {KerberosClient kerberosClient = new KerberosClient(conf, hadoopConf);File keytabFile = kerberosClient.saveKeyTabFileFromUri(catalogInfo.id());this.kerberosRealm = kerberosClient.login(keytabFile.getAbsolutePath());} catch (IOException e) {- throw new RuntimeException("Failed to login with kerberos", e);+ throw new RuntimeException("Failed to login with Kerberos", e);}}}diff --git a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/AuthenticationConfig.java b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/AuthenticationConfig.javaindex 2128231a3f..8d9549c57b 100644--- a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/AuthenticationConfig.java+++ b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/AuthenticationConfig.java@@ -5,6 +5,8 @@package com.datastrato.gravitino.catalog.hadoop.kerberos;+import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.DEFAULT_IMPERSONATION_ENABLE;+import com.datastrato.gravitino.Config;import com.datastrato.gravitino.config.ConfigBuilder;import com.datastrato.gravitino.config.ConfigConstants;@@ -14,53 +16,56 @@ import com.google.common.collect.ImmutableMap;import java.util.Map;public class AuthenticationConfig extends Config {- public static final String ENABLE_AUTH_KEY = "authentication.enable";++ // The key for the authentication type, currently we support Kerberos and simplepublic static final String AUTH_TYPE_KEY = "authentication.type";+ public static final String IMPERSONATION_ENABLE_KEY = "authentication.impersonation-enable";+public AuthenticationConfig(Map<String, String> properties) {super(false);loadFromMap(properties, k -> true);}- public static final ConfigEntry<Boolean> ENABLE_AUTH_ENTRY =- new ConfigBuilder(ENABLE_AUTH_KEY)- .doc("Whether to enable authentication for Hadoop catalog")- .version(ConfigConstants.VERSION_0_5_1)- .booleanConf()- .createWithDefault(false);-public static final ConfigEntry<String> AUTH_TYPE_ENTRY =new ConfigBuilder(AUTH_TYPE_KEY)- .doc("The type of authentication for Hadoop catalog, currently we only support kerberos")+ .doc("The type of authentication for Hadoop catalog, currently we only support Kerberos").version(ConfigConstants.VERSION_0_5_1).stringConf().create();- public boolean isEnableAuth() {- return get(ENABLE_AUTH_ENTRY);- }+ public static final ConfigEntry<Boolean> ENABLE_IMPERSONATION_ENTRY =+ new ConfigBuilder(IMPERSONATION_ENABLE_KEY)+ .doc("Whether to enable impersonation for the Hadoop catalog")+ .version(ConfigConstants.VERSION_0_5_1)+ .booleanConf()+ .createWithDefault(DEFAULT_IMPERSONATION_ENABLE);public String getAuthType() {return get(AUTH_TYPE_ENTRY);}+ public boolean isImpersonationEnabled() {+ return get(ENABLE_IMPERSONATION_ENTRY);+ }+public static final Map<String, PropertyEntry<?>> AUTHENTICATION_PROPERTY_ENTRIES =new ImmutableMap.Builder<String, PropertyEntry<?>>().put(- ENABLE_AUTH_KEY,+ IMPERSONATION_ENABLE_KEY,PropertyEntry.booleanPropertyEntry(- ENABLE_AUTH_KEY,- "Whether to enable authentication for Hadoop catalog",+ IMPERSONATION_ENABLE_KEY,+ "Whether to enable impersonation for the Hadoop catalog",false,true,- false,+ DEFAULT_IMPERSONATION_ENABLE,false,false)).put(AUTH_TYPE_KEY,PropertyEntry.stringImmutablePropertyEntry(AUTH_TYPE_KEY,- "The type of authentication for Hadoop catalog, currently we only support kerberos",+ "The type of authentication for Hadoop catalog, currently we only support Kerberos",false,null,false,diff --git a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/KerberosConfig.java b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/KerberosConfig.javaindex 7e2686a47a..60f5b8469c 100644--- a/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/KerberosConfig.java+++ b/catalogs/catalog-hadoop/src/main/java/com/datastrato/gravitino/catalog/hadoop/kerberos/KerberosConfig.java@@ -23,14 +23,11 @@ public class KerberosConfig extends AuthenticationConfig {public static final String FETCH_TIMEOUT_SEC_KEY ="authentication.kerberos.keytab-fetch-timeout-sec";- public static final String IMPERSONATION_ENABLE_KEY =- "authentication.kerberos.impersonation-enable";-public static final boolean DEFAULT_IMPERSONATION_ENABLE = false;public static final ConfigEntry<String> PRINCIPAL_ENTRY =new ConfigBuilder(PRINCIPAL_KEY)- .doc("The principal of the kerberos connection")+ .doc("The principal of the Kerberos connection").version(ConfigConstants.VERSION_0_5_1).stringConf().checkValue(StringUtils::isNotBlank, ConfigConstants.NOT_BLANK_ERROR_MSG)@@ -38,7 +35,7 @@ public class KerberosConfig extends AuthenticationConfig {public static final ConfigEntry<String> KEYTAB_ENTRY =new ConfigBuilder(KEY_TAB_URI_KEY)- .doc("The keytab of the kerberos connection")+ .doc("The keytab of the Kerberos connection").version(ConfigConstants.VERSION_0_5_1).stringConf().checkValue(StringUtils::isNotBlank, ConfigConstants.NOT_BLANK_ERROR_MSG)@@ -46,7 +43,7 @@ public class KerberosConfig extends AuthenticationConfig {public static final ConfigEntry<Integer> CHECK_INTERVAL_SEC_ENTRY =new ConfigBuilder(CHECK_INTERVAL_SEC_KEY)- .doc("The check interval of the kerberos connection for Hadoop catalog")+ .doc("The check interval of the Kerberos connection for Hadoop catalog").version(ConfigConstants.VERSION_0_5_1).intConf().checkValue(value -> value > 0, ConfigConstants.POSITIVE_NUMBER_ERROR_MSG)@@ -54,28 +51,17 @@ public class KerberosConfig extends AuthenticationConfig {public static final ConfigEntry<Integer> FETCH_TIMEOUT_SEC_ENTRY =new ConfigBuilder(FETCH_TIMEOUT_SEC_KEY)- .doc("The fetch timeout of the kerberos connection")+ .doc("The fetch timeout of the Kerberos connection").version(ConfigConstants.VERSION_0_5_1).intConf().checkValue(value -> value > 0, ConfigConstants.POSITIVE_NUMBER_ERROR_MSG).createWithDefault(2);- public static final ConfigEntry<Boolean> ENABLE_IMPERSONATION_ENTRY =- new ConfigBuilder(IMPERSONATION_ENABLE_KEY)- .doc("Whether to enable impersonation for the Hadoop catalog")- .version(ConfigConstants.VERSION_0_5_1)- .booleanConf()- .createWithDefault(DEFAULT_IMPERSONATION_ENABLE);-public KerberosConfig(Map<String, String> properties) {super(properties);loadFromMap(properties, k -> true);}- public boolean isImpersonationEnabled() {- return get(ENABLE_IMPERSONATION_ENTRY);- }-public String getPrincipalName() {return get(PRINCIPAL_ENTRY);}@@ -94,16 +80,6 @@ public class KerberosConfig extends AuthenticationConfig {public static final Map<String, PropertyEntry<?>> KERBEROS_PROPERTY_ENTRIES =new ImmutableMap.Builder<String, PropertyEntry<?>>()- .put(- IMPERSONATION_ENABLE_KEY,- PropertyEntry.booleanPropertyEntry(- IMPERSONATION_ENABLE_KEY,- "Whether to enable impersonation for the Hadoop catalog",- false,- true,- DEFAULT_IMPERSONATION_ENABLE,- false,- false)).put(KEY_TAB_URI_KEY,PropertyEntry.stringImmutablePropertyEntry(diff --git a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.javaindex fb546dedc9..030283c34d 100644--- a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java+++ b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserAuthenticationIT.java@@ -6,7 +6,6 @@package com.datastrato.gravitino.catalog.hadoop.integration.test;import static com.datastrato.gravitino.catalog.hadoop.kerberos.AuthenticationConfig.AUTH_TYPE_KEY;-import static com.datastrato.gravitino.catalog.hadoop.kerberos.AuthenticationConfig.ENABLE_AUTH_KEY;import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.IMPERSONATION_ENABLE_KEY;import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.KEY_TAB_URI_KEY;import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.PRINCIPAL_KEY;@@ -168,7 +167,6 @@ public class HadoopUserAuthenticationIT extends AbstractIT {// Create a catalogMap<String, String> properties = Maps.newHashMap();- properties.put(ENABLE_AUTH_KEY, "true");properties.put(AUTH_TYPE_KEY, "kerberos");properties.put(IMPERSONATION_ENABLE_KEY, "true");properties.put(KEY_TAB_URI_KEY, TMP_DIR + HADOOP_CLIENT_KEYTAB);diff --git a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.javaindex e4b8c617ee..ead0eb57ab 100644--- a/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java+++ b/catalogs/catalog-hadoop/src/test/java/com/datastrato/gravitino/catalog/hadoop/integration/test/HadoopUserImpersonationIT.java@@ -6,7 +6,6 @@package com.datastrato.gravitino.catalog.hadoop.integration.test;import static com.datastrato.gravitino.catalog.hadoop.kerberos.AuthenticationConfig.AUTH_TYPE_KEY;-import static com.datastrato.gravitino.catalog.hadoop.kerberos.AuthenticationConfig.ENABLE_AUTH_KEY;import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.IMPERSONATION_ENABLE_KEY;import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.KEY_TAB_URI_KEY;import static com.datastrato.gravitino.catalog.hadoop.kerberos.KerberosConfig.PRINCIPAL_KEY;@@ -253,7 +252,6 @@ public class HadoopUserImpersonationIT extends AbstractIT {private static void createCatalog() {ImmutableMap<String, String> catalogProperties =new ImmutableMap.Builder<String, String>()- .put(ENABLE_AUTH_KEY, "true").put(AUTH_TYPE_KEY, "kerberos").put(IMPERSONATION_ENABLE_KEY, "true").put(PRINCIPAL_KEY, SERVER_PRINCIPAL + "@" + kdc.getRealm())diff --git a/docs/hadoop-catalog.md b/docs/hadoop-catalog.mdindex 7b411c9a1a..94dd0c0592 100644--- a/docs/hadoop-catalog.md+++ b/docs/hadoop-catalog.md@@ -24,9 +24,15 @@ Hadoop 3. If there's any compatibility issue, please create an [issue](https://g### Catalog properties-| Property Name | Description | Default Value | Required | Since Version |-|---------------|-------------------------------------------------|---------------|----------|---------------|-| `location` | The storage location managed by Hadoop catalog. | (none) | No | 0.5.0 |+| Property Name | Description | Default Value | Required | Since Version |+|----------------------------------------------------|------------------------------------------------------------------------------------------------|---------------|-------------------------------------------------------------|---------------|+| `location` | The storage location managed by Hadoop catalog. | (none) | No | 0.5.0 |+| `authentication.type` | The type of authentication for Hadoop catalog, currently we only support `kerberos`, `simple`. | `simple` | No | 0.5.1 |+| `authentication.impersonation-enable` | Whether to enable impersonation for the Hadoop catalog. | `false` | No | 0.5.1 |+| `authentication.kerberos.principal` | The principal of the Kerberos authentication | (none) | required if the value of `authentication.type` is Kerberos. | 0.5.1 |+| `authentication.kerberos.keytab-uri` | The URI of The keytab for the Kerberos authentication. | (none) | required if the value of `authentication.type` is Kerberos. | 0.5.1 |+| `authentication.kerberos.check-interval-sec` | The check interval of Kerberos credential for Hadoop catalog. | 60 | No | 0.5.1 |+| `authentication.kerberos.keytab-fetch-timeout-sec` | The fetch timeout of retrieving Kerberos keytab from `authentication.kerberos.keytab-uri`. | 60 | No | 0.5.1 |### Catalog operations