You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "lasdf1234 (via GitHub)" <gi...@apache.org> on 2026/06/05 09:17:59 UTC
[PR] [#11443] feat(connector): Add Basic auth for Spark, Flink, and Trino [gravitino]
lasdf1234 opened a new pull request, #11457:
URL: https://github.com/apache/gravitino/pull/11457
### What changes were proposed in this pull request?
Add HTTP Basic authentication support to the Spark, Flink, and Trino connectors so they can
authenticate against the Gravitino built-in IDP:
- **catalog-common**: add `BASIC_AUTH_TYPE`, `isBasic()`, and shared `basic.username` /
`basic.password` property keys in `AuthProperties`.
- **Spark**: `GravitinoSparkConfig` properties and `basic` branch in
`GravitinoDriverPlugin.createGravitinoClient()`.
- **Flink**: `basic` auth in `GravitinoCatalogManager` and
`GravitinoCatalogStoreFactoryOptions`.
- **Trino**: `basic` auth in `GravitinoAuthProvider`.
- **Docs**: update Spark/Flink/Trino connector authentication documentation.
- **Tests**: unit tests for Flink/Trino; integration tests `SparkBasicAuthIT`,
`FlinkBasicAuthIT`, and `TrinoBasicAuthIT`.
### Why are the changes needed?
The built-in IDP requires HTTP Basic Authentication, but the Spark/Flink/Trino connectors only
supported `simple`, `oauth2`, and `kerberos`. Users could not connect through these connectors
with built-in IDP credentials even though the Java client already supports `withBasicAuth()`.
Fix: #11443
### Does this PR introduce _any_ user-facing change?
Yes. New optional connector configuration for Basic auth:
| Connector | Properties |
|-----------|------------|
| Spark | `spark.sql.gravitino.authType=basic`, `spark.sql.gravitino.basic.username`, `spark.sql.gravitino.basic.password` |
| Flink | `table.catalog-store.gravitino.gravitino.client.auth.type=basic`, `...basic.username`, `...basic.password` |
| Trino | `gravitino.client.authType=basic`, `gravitino.client.basic.username`, `gravitino.client.basic.password` |
### How was this patch tested?
- `./gradlew :flink-connector:flink-common:test --tests "org.apache.gravitino.flink.connector.store.TestGravitinoFlinkConfig" -PskipITs`
- `./gradlew :trino-connector:trino-connector:test --tests "org.apache.gravitino.trino.connector.security.TestGravitinoAuthProvider" -PskipITs`
- Integration tests (require Docker): `SparkBasicAuthIT`, `FlinkBasicAuthIT`, `TrinoBasicAuthIT`
Made with [Cursor](https://cursor.com)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#issuecomment-4657226151
Please update description of this PR
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#issuecomment-4657334362
> Please update description of this PR
Got Description has been updated.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3371744971
##########
trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoBasicAuthIT.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.trino.connector.integration.test;
+
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * End-to-end integration test for Trino connector Basic authentication against the built-in IdP.
+ * Verifies HTTP Basic credentials against Gravitino REST with the built-in IdP. Trino catalog
+ * properties {@code gravitino.client.authType=basic}, {@code gravitino.client.basic.username}, and
+ * {@code gravitino.client.basic.password} are mapped to {@link
+ * GravitinoAdminClient.AdminClientBuilder#withBasicAuth(String, String)} by the connector;
+ * connector-side config parsing is covered by {@code TestGravitinoAuthProvider#testBuildBasicAuth}.
+ */
+public class TrinoBasicAuthIT extends BaseIT {
+
Review Comment:
Thank you very much for your suggestion.I have restructured this method and it will conduct the basic authentication test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "jerryshao (via GitHub)" <gi...@apache.org>.
jerryshao merged PR #11457:
URL: https://github.com/apache/gravitino/pull/11457
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3370706544
##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/catalog/FlinkBasicAuthIT.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.flink.connector.integration.test.catalog;
+
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.internal.TableEnvironmentImpl;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.flink.connector.store.GravitinoCatalogStoreFactoryOptions;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * End-to-end integration test for Flink Basic authentication against the built-in IdP. Exercises
+ * the full path: Flink catalog store → HTTP Basic credentials → Gravitino REST → built-in IdP
+ * validation.
+ */
+public class FlinkBasicAuthIT extends BaseIT {
+
+ private static final String METALAKE = "flink_basic_auth";
+ private static final String ADMIN = "admin";
+ private static final String ADMIN_PASSWORD = "Passw0rd-For-Admin1";
+ private static final String IDP_REST_EXTENSION_PACKAGE =
+ "org.apache.gravitino.idp.web.rest.feature";
+
+ private static String gravitinoUri;
+
+ private static TableEnvironment tableEnv;
+
+ @BeforeAll
+ @Override
+ public void startIntegrationTest() throws Exception {
+ setEnv("GRAVITINO_INITIAL_ADMIN_PASSWORD", ADMIN_PASSWORD);
+ Map<String, String> configs = Maps.newHashMap();
+ configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(false));
+ configs.put(Configs.CACHE_ENABLED.getKey(), String.valueOf(false));
+ configs.put(Configs.SERVICE_ADMINS.getKey(), ADMIN);
+ configs.put(Configs.REST_API_EXTENSION_PACKAGES.getKey(), IDP_REST_EXTENSION_PACKAGE);
+ registerCustomConfigs(configs);
+ super.startIntegrationTest();
+
+ gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort());
+ try (GravitinoAdminClient adminClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ adminClient.createMetalake(METALAKE, "Flink basic auth test metalake", Maps.newHashMap());
+ }
+
+ Configuration configuration = new Configuration();
+ configuration.setString(
+ "table.catalog-store.kind", GravitinoCatalogStoreFactoryOptions.GRAVITINO);
+ configuration.setString("table.catalog-store.gravitino.gravitino.metalake", METALAKE);
+ configuration.setString("table.catalog-store.gravitino.gravitino.uri", gravitinoUri);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.AUTH_TYPE,
+ GravitinoCatalogStoreFactoryOptions.BASIC);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME,
+ ADMIN);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD,
+ ADMIN_PASSWORD);
+
+ EnvironmentSettings.Builder builder =
+ EnvironmentSettings.newInstance().withConfiguration(configuration);
+ tableEnv = TableEnvironment.create(builder.inBatchMode().build());
+ }
+
+ @AfterAll
+ @Override
+ public void stopIntegrationTest() throws IOException, InterruptedException {
+ if (tableEnv != null) {
+ try {
+ TableEnvironmentImpl env = (TableEnvironmentImpl) tableEnv;
+ env.getCatalogManager().close();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to close Flink table environment", e);
+ }
+ }
+ super.stopIntegrationTest();
+ }
+
+ @Test
+ public void testFlinkConnectsWithBasicAuth() {
+ Assertions.assertDoesNotThrow(() -> tableEnv.executeSql("SHOW CATALOGS").print());
+
+ try (GravitinoAdminClient basicClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ GravitinoMetalake loadedMetalake = basicClient.loadMetalake(METALAKE);
+ Assertions.assertEquals(METALAKE, loadedMetalake.name());
Review Comment:
The integration test you added cannot verify whether Spark, Trino, and Flink can connect to the Gravitino server. It is more like a basic authentication test between the Gravitino client and the Gravitino server.
##########
trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoBasicAuthIT.java:
##########
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.trino.connector.integration.test;
+
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * End-to-end integration test for Trino connector Basic authentication against the built-in IdP.
+ * Verifies HTTP Basic credentials against Gravitino REST with the built-in IdP. Trino catalog
+ * properties {@code gravitino.client.authType=basic}, {@code gravitino.client.basic.username}, and
+ * {@code gravitino.client.basic.password} are mapped to {@link
+ * GravitinoAdminClient.AdminClientBuilder#withBasicAuth(String, String)} by the connector;
+ * connector-side config parsing is covered by {@code TestGravitinoAuthProvider#testBuildBasicAuth}.
+ */
+public class TrinoBasicAuthIT extends BaseIT {
+
Review Comment:
This test has nothing to do with Trino, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3378118103
##########
trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoBasicAuthIT.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.trino.connector.integration.test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.GenericContainer;
+
+/**
+ * End-to-end integration test for Trino connector Basic authentication against the built-in IdP.
+ * Exercises the full path: Trino connector plugin → HTTP Basic credentials → Gravitino REST →
+ * built-in IdP validation.
+ */
+@Tag("gravitino-docker-test")
+public class TrinoBasicAuthIT {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TrinoBasicAuthIT.class);
+
+ private static final String METALAKE = "trino_basic_auth";
+ private static final String ADMIN = "admin";
+ private static final String ADMIN_PASSWORD = "Passw0rd-For-Admin1";
+ private static final String IDP_REST_EXTENSION_PACKAGE =
+ "org.apache.gravitino.idp.web.rest.feature";
+ private static final int TRINO_PORT = 8080;
+
+ private static BaseIT baseIT;
+ private static GenericContainer<?> trinoContainer;
+ private static Path trinoConfigDir;
+ private static TrinoQueryRunner trinoQueryRunner;
+
+ @BeforeAll
+ static void setUp() throws Exception {
+ baseIT = new BaseIT();
+ BaseIT.setEnv("GRAVITINO_INITIAL_ADMIN_PASSWORD", ADMIN_PASSWORD);
+ baseIT.registerCustomConfigs(idpConfigs());
+ baseIT.startIntegrationTest();
+
+ String gravitinoUri = String.format("http://127.0.0.1:%d", baseIT.getGravitinoServerPort());
+ try (GravitinoAdminClient adminClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ adminClient.createMetalake(METALAKE, "Trino basic auth test metalake", Maps.newHashMap());
+ }
+
+ trinoConfigDir =
+ prepareTrinoConfigDir(baseIT.getGravitinoServerPort(), METALAKE, ADMIN, ADMIN_PASSWORD);
+ trinoContainer = startTrinoContainer(trinoConfigDir, trinoConnectorDir());
+ trinoQueryRunner =
+ new TrinoQueryRunner(
+ String.format("http://127.0.0.1:%d", trinoContainer.getMappedPort(TRINO_PORT)));
+ }
+
+ @AfterAll
+ static void tearDown() throws IOException, InterruptedException {
+ if (trinoQueryRunner != null) {
+ trinoQueryRunner.stop();
+ }
+ if (trinoContainer != null) {
+ trinoContainer.stop();
+ }
+ if (trinoConfigDir != null) {
+ try {
+ FileUtils.deleteDirectory(trinoConfigDir.toFile());
+ } catch (IOException e) {
+ LOG.warn("Failed to delete temporary Trino config directory {}", trinoConfigDir, e);
+ }
+ }
+ if (baseIT != null) {
+ baseIT.stopIntegrationTest();
+ }
+ }
+
+ @Test
+ void testTrinoConnectorConnectsWithBasicAuth() {
+ Assertions.assertDoesNotThrow(() -> trinoQueryRunner.runQuery("SHOW CATALOGS"));
Review Comment:
Thank you very much for your suggestion. I have followed the method you mentioned and deleted the unnecessary IT, and also added the IT for the basic client. Additionally, I have already set up Trino/Spark/Flink clusters locally and successfully implemented basic authentication(Tested the create/select/insert table operations).
##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/catalog/FlinkBasicAuthIT.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.flink.connector.integration.test.catalog;
+
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.internal.TableEnvironmentImpl;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.flink.connector.store.GravitinoCatalogStoreFactoryOptions;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * End-to-end integration test for Flink Basic authentication against the built-in IdP. Exercises
+ * the full path: Flink catalog store → HTTP Basic credentials → Gravitino REST → built-in IdP
+ * validation.
+ */
+public class FlinkBasicAuthIT extends BaseIT {
+
+ private static final String METALAKE = "flink_basic_auth";
+ private static final String ADMIN = "admin";
+ private static final String ADMIN_PASSWORD = "Passw0rd-For-Admin1";
+ private static final String IDP_REST_EXTENSION_PACKAGE =
+ "org.apache.gravitino.idp.web.rest.feature";
+
+ private static String gravitinoUri;
+
+ private static TableEnvironment tableEnv;
+
+ @BeforeAll
+ @Override
+ public void startIntegrationTest() throws Exception {
+ setEnv("GRAVITINO_INITIAL_ADMIN_PASSWORD", ADMIN_PASSWORD);
+ Map<String, String> configs = Maps.newHashMap();
+ configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(false));
+ configs.put(Configs.CACHE_ENABLED.getKey(), String.valueOf(false));
+ configs.put(Configs.SERVICE_ADMINS.getKey(), ADMIN);
+ configs.put(Configs.REST_API_EXTENSION_PACKAGES.getKey(), IDP_REST_EXTENSION_PACKAGE);
+ registerCustomConfigs(configs);
+ super.startIntegrationTest();
+
+ gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort());
+ try (GravitinoAdminClient adminClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ adminClient.createMetalake(METALAKE, "Flink basic auth test metalake", Maps.newHashMap());
+ }
+
+ Configuration configuration = new Configuration();
+ configuration.setString(
+ "table.catalog-store.kind", GravitinoCatalogStoreFactoryOptions.GRAVITINO);
+ configuration.setString("table.catalog-store.gravitino.gravitino.metalake", METALAKE);
+ configuration.setString("table.catalog-store.gravitino.gravitino.uri", gravitinoUri);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.AUTH_TYPE,
+ GravitinoCatalogStoreFactoryOptions.BASIC);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME,
+ ADMIN);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD,
+ ADMIN_PASSWORD);
+
+ EnvironmentSettings.Builder builder =
+ EnvironmentSettings.newInstance().withConfiguration(configuration);
+ tableEnv = TableEnvironment.create(builder.inBatchMode().build());
+ }
+
+ @AfterAll
+ @Override
+ public void stopIntegrationTest() throws IOException, InterruptedException {
+ if (tableEnv != null) {
+ try {
+ TableEnvironmentImpl env = (TableEnvironmentImpl) tableEnv;
+ env.getCatalogManager().close();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to close Flink table environment", e);
+ }
+ }
+ super.stopIntegrationTest();
+ }
+
+ @Test
+ public void testFlinkConnectsWithBasicAuth() {
+ Assertions.assertDoesNotThrow(() -> tableEnv.executeSql("SHOW CATALOGS").print());
+
+ try (GravitinoAdminClient basicClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ GravitinoMetalake loadedMetalake = basicClient.loadMetalake(METALAKE);
+ Assertions.assertEquals(METALAKE, loadedMetalake.name());
Review Comment:
Thank you very much for your suggestion. I have followed the method you mentioned and deleted the unnecessary IT, and also added the IT for the basic client. Additionally, I have already set up Trino/Spark/Flink clusters locally and successfully implemented basic authentication(Tested the create/select/insert table operations).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(connector): Add Basic auth for Spark, Flink, and Trino [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 closed pull request #11457: [#11443] feat(connector): Add Basic auth for Spark, Flink, and Trino
URL: https://github.com/apache/gravitino/pull/11457
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3377401360
##########
trino-connector/integration-test/src/test/java/org/apache/gravitino/trino/connector/integration/test/TrinoBasicAuthIT.java:
##########
@@ -0,0 +1,210 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.trino.connector.integration.test;
+
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.io.FileUtils;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.GenericContainer;
+
+/**
+ * End-to-end integration test for Trino connector Basic authentication against the built-in IdP.
+ * Exercises the full path: Trino connector plugin → HTTP Basic credentials → Gravitino REST →
+ * built-in IdP validation.
+ */
+@Tag("gravitino-docker-test")
+public class TrinoBasicAuthIT {
+
+ private static final Logger LOG = LoggerFactory.getLogger(TrinoBasicAuthIT.class);
+
+ private static final String METALAKE = "trino_basic_auth";
+ private static final String ADMIN = "admin";
+ private static final String ADMIN_PASSWORD = "Passw0rd-For-Admin1";
+ private static final String IDP_REST_EXTENSION_PACKAGE =
+ "org.apache.gravitino.idp.web.rest.feature";
+ private static final int TRINO_PORT = 8080;
+
+ private static BaseIT baseIT;
+ private static GenericContainer<?> trinoContainer;
+ private static Path trinoConfigDir;
+ private static TrinoQueryRunner trinoQueryRunner;
+
+ @BeforeAll
+ static void setUp() throws Exception {
+ baseIT = new BaseIT();
+ BaseIT.setEnv("GRAVITINO_INITIAL_ADMIN_PASSWORD", ADMIN_PASSWORD);
+ baseIT.registerCustomConfigs(idpConfigs());
+ baseIT.startIntegrationTest();
+
+ String gravitinoUri = String.format("http://127.0.0.1:%d", baseIT.getGravitinoServerPort());
+ try (GravitinoAdminClient adminClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ adminClient.createMetalake(METALAKE, "Trino basic auth test metalake", Maps.newHashMap());
+ }
+
+ trinoConfigDir =
+ prepareTrinoConfigDir(baseIT.getGravitinoServerPort(), METALAKE, ADMIN, ADMIN_PASSWORD);
+ trinoContainer = startTrinoContainer(trinoConfigDir, trinoConnectorDir());
+ trinoQueryRunner =
+ new TrinoQueryRunner(
+ String.format("http://127.0.0.1:%d", trinoContainer.getMappedPort(TRINO_PORT)));
+ }
+
+ @AfterAll
+ static void tearDown() throws IOException, InterruptedException {
+ if (trinoQueryRunner != null) {
+ trinoQueryRunner.stop();
+ }
+ if (trinoContainer != null) {
+ trinoContainer.stop();
+ }
+ if (trinoConfigDir != null) {
+ try {
+ FileUtils.deleteDirectory(trinoConfigDir.toFile());
+ } catch (IOException e) {
+ LOG.warn("Failed to delete temporary Trino config directory {}", trinoConfigDir, e);
+ }
+ }
+ if (baseIT != null) {
+ baseIT.stopIntegrationTest();
+ }
+ }
+
+ @Test
+ void testTrinoConnectorConnectsWithBasicAuth() {
+ Assertions.assertDoesNotThrow(() -> trinoQueryRunner.runQuery("SHOW CATALOGS"));
Review Comment:
Your test only relies on SHOW CATALOGS, which is insufficient to validate your changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3369479812
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/GravitinoCatalogManager.java:
##########
@@ -244,6 +247,37 @@ private static boolean checkEqual(
&& gravitinoCatalogManager.gravitinoClientConfig.equals(gravitinoClientConfig);
}
+ private static GravitinoAdminClient buildBasicClient(
+ String gravitinoUri, Map<String, String> config) {
+ String username = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME);
+ String password = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD);
+ if (Strings.isNullOrEmpty(username)) {
Review Comment:
Got resolved.
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/GravitinoCatalogManager.java:
##########
@@ -244,6 +247,37 @@ private static boolean checkEqual(
&& gravitinoCatalogManager.gravitinoClientConfig.equals(gravitinoClientConfig);
}
+ private static GravitinoAdminClient buildBasicClient(
+ String gravitinoUri, Map<String, String> config) {
+ String username = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME);
+ String password = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD);
+ if (Strings.isNullOrEmpty(username)) {
+ throw new IllegalArgumentException(
Review Comment:
Got resolved.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/security/GravitinoAuthProvider.java:
##########
@@ -230,6 +245,21 @@ private static void buildSimpleAuth(
}
}
+ private static void buildBasicAuth(
+ GravitinoAdminClient.AdminClientBuilder builder, Map<String, String> config) {
+ String username = config.get(BASIC_USERNAME_KEY);
+ String password = config.get(BASIC_PASSWORD_KEY);
+ if (StringUtils.isBlank(username)) {
Review Comment:
Got resolved.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "lasdf1234 (via GitHub)" <gi...@apache.org>.
lasdf1234 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3371750899
##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/catalog/FlinkBasicAuthIT.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.flink.connector.integration.test.catalog;
+
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.internal.TableEnvironmentImpl;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.flink.connector.store.GravitinoCatalogStoreFactoryOptions;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * End-to-end integration test for Flink Basic authentication against the built-in IdP. Exercises
+ * the full path: Flink catalog store → HTTP Basic credentials → Gravitino REST → built-in IdP
+ * validation.
+ */
+public class FlinkBasicAuthIT extends BaseIT {
+
+ private static final String METALAKE = "flink_basic_auth";
+ private static final String ADMIN = "admin";
+ private static final String ADMIN_PASSWORD = "Passw0rd-For-Admin1";
+ private static final String IDP_REST_EXTENSION_PACKAGE =
+ "org.apache.gravitino.idp.web.rest.feature";
+
+ private static String gravitinoUri;
+
+ private static TableEnvironment tableEnv;
+
+ @BeforeAll
+ @Override
+ public void startIntegrationTest() throws Exception {
+ setEnv("GRAVITINO_INITIAL_ADMIN_PASSWORD", ADMIN_PASSWORD);
+ Map<String, String> configs = Maps.newHashMap();
+ configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(false));
+ configs.put(Configs.CACHE_ENABLED.getKey(), String.valueOf(false));
+ configs.put(Configs.SERVICE_ADMINS.getKey(), ADMIN);
+ configs.put(Configs.REST_API_EXTENSION_PACKAGES.getKey(), IDP_REST_EXTENSION_PACKAGE);
+ registerCustomConfigs(configs);
+ super.startIntegrationTest();
+
+ gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort());
+ try (GravitinoAdminClient adminClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ adminClient.createMetalake(METALAKE, "Flink basic auth test metalake", Maps.newHashMap());
+ }
+
+ Configuration configuration = new Configuration();
+ configuration.setString(
+ "table.catalog-store.kind", GravitinoCatalogStoreFactoryOptions.GRAVITINO);
+ configuration.setString("table.catalog-store.gravitino.gravitino.metalake", METALAKE);
+ configuration.setString("table.catalog-store.gravitino.gravitino.uri", gravitinoUri);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.AUTH_TYPE,
+ GravitinoCatalogStoreFactoryOptions.BASIC);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME,
+ ADMIN);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD,
+ ADMIN_PASSWORD);
+
+ EnvironmentSettings.Builder builder =
+ EnvironmentSettings.newInstance().withConfiguration(configuration);
+ tableEnv = TableEnvironment.create(builder.inBatchMode().build());
+ }
+
+ @AfterAll
+ @Override
+ public void stopIntegrationTest() throws IOException, InterruptedException {
+ if (tableEnv != null) {
+ try {
+ TableEnvironmentImpl env = (TableEnvironmentImpl) tableEnv;
+ env.getCatalogManager().close();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to close Flink table environment", e);
+ }
+ }
+ super.stopIntegrationTest();
+ }
+
+ @Test
+ public void testFlinkConnectsWithBasicAuth() {
+ Assertions.assertDoesNotThrow(() -> tableEnv.executeSql("SHOW CATALOGS").print());
+
+ try (GravitinoAdminClient basicClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ GravitinoMetalake loadedMetalake = basicClient.loadMetalake(METALAKE);
+ Assertions.assertEquals(METALAKE, loadedMetalake.name());
Review Comment:
Thank you very much for your suggestion.I have restructured this method and it will conduct the basic authentication test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(connector): Add Basic auth for Spark, Flink, and Trino [gravitino]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#issuecomment-4631362387
<!-- coverage-report -->
### Code Coverage Report
|Overall Project|66.95% **`-0.12%`**|:green_circle:|
|:-|:-|:-:|
|Files changed|39.28%|:red_circle:|
<br>
|Module|Coverage||
|:-|:-|:-:|
|aliyun|1.72%|:red_circle:|
|api|46.8%|:green_circle:|
|authorization-common|85.96%|:green_circle:|
|aws|3.66%|:red_circle:|
|azure|2.47%|:red_circle:|
|catalog-common|10.02% **`-0.08%`**|:red_circle:|
|catalog-fileset|80.35%|:green_circle:|
|catalog-glue|66.67%|:green_circle:|
|catalog-hive|79.35%|:green_circle:|
|catalog-jdbc-clickhouse|80.02%|:green_circle:|
|catalog-jdbc-common|45.31%|:green_circle:|
|catalog-jdbc-doris|80.28%|:green_circle:|
|catalog-jdbc-hologres|54.03%|:green_circle:|
|catalog-jdbc-mysql|79.23%|:green_circle:|
|catalog-jdbc-oceanbase|78.38%|:green_circle:|
|catalog-jdbc-postgresql|82.29%|:green_circle:|
|catalog-jdbc-starrocks|78.51%|:green_circle:|
|catalog-kafka|77.01%|:green_circle:|
|catalog-lakehouse-generic|44.89%|:green_circle:|
|catalog-lakehouse-hudi|79.1%|:green_circle:|
|catalog-lakehouse-iceberg|85.74%|:green_circle:|
|catalog-lakehouse-paimon|79.29%|:green_circle:|
|catalog-model|77.72%|:green_circle:|
|cli|44.51%|:green_circle:|
|client-java|77.91%|:green_circle:|
|common|50.17%|:green_circle:|
|core|82.49%|:green_circle:|
|filesystem-hadoop3|76.97%|:green_circle:|
|flink|0.0%|:red_circle:|
|flink-common|47.39% **`-0.88%`**|:green_circle:|
|flink-runtime|0.0%|:red_circle:|
|gcp|14.12%|:red_circle:|
|hadoop-common|10.39%|:red_circle:|
|hive-metastore-common|53.42%|:green_circle:|
|iceberg-common|56.54%|:green_circle:|
|iceberg-rest-server|73.5%|:green_circle:|
|idp-basic|85.99%|:green_circle:|
|integration-test-common|0.0%|:red_circle:|
|jobs|66.17%|:green_circle:|
|lance-common|20.83%|:red_circle:|
|lance-rest-server|60.27%|:green_circle:|
|lineage|53.02%|:green_circle:|
|optimizer|82.87%|:green_circle:|
|optimizer-api|21.95%|:red_circle:|
|server|85.73%|:green_circle:|
|server-common|73.28%|:green_circle:|
|spark|29.85%|:red_circle:|
|spark-common|40.92% **`-2.73%`**|:green_circle:|
|trino-connector|40.11% **`+1.24%`**|:green_circle:|
<details>
<summary>Files</summary>
|Module|File|Coverage||
|:-|:-|:-|:-:|
|catalog-common|[AuthProperties.java](https://github.com/lasdf1234/gravitino/blob/7522816ccb3f8927f12e5d8b76900571399b83f5/catalogs/catalog-common/src/main/java/org/apache/gravitino/auth/AuthProperties.java)|0.0%|:red_circle:|
|flink-common|[GravitinoCatalogStoreFactoryOptions.java](https://github.com/lasdf1234/gravitino/blob/7522816ccb3f8927f12e5d8b76900571399b83f5/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/store/GravitinoCatalogStoreFactoryOptions.java)|100.0%|:green_circle:|
||[GravitinoCatalogManager.java](https://github.com/lasdf1234/gravitino/blob/7522816ccb3f8927f12e5d8b76900571399b83f5/flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/GravitinoCatalogManager.java)|26.79%|:red_circle:|
|spark-common|[GravitinoDriverPlugin.java](https://github.com/lasdf1234/gravitino/blob/7522816ccb3f8927f12e5d8b76900571399b83f5/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/plugin/GravitinoDriverPlugin.java)|6.82%|:red_circle:|
||[GravitinoSparkConfig.java](https://github.com/lasdf1234/gravitino/blob/7522816ccb3f8927f12e5d8b76900571399b83f5/spark-connector/spark-common/src/main/java/org/apache/gravitino/spark/connector/GravitinoSparkConfig.java)|0.0%|:red_circle:|
|trino-connector|[GravitinoAuthProvider.java](https://github.com/lasdf1234/gravitino/blob/7522816ccb3f8927f12e5d8b76900571399b83f5/trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/security/GravitinoAuthProvider.java)|78.15%|:green_circle:|
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "diqiu50 (via GitHub)" <gi...@apache.org>.
diqiu50 commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3377373564
##########
flink-connector/flink-common/src/test/java/org/apache/gravitino/flink/connector/integration/test/catalog/FlinkBasicAuthIT.java:
##########
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.flink.connector.integration.test.catalog;
+
+import com.google.common.collect.Maps;
+import java.io.IOException;
+import java.util.Map;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.TableEnvironment;
+import org.apache.flink.table.api.internal.TableEnvironmentImpl;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.client.GravitinoAdminClient;
+import org.apache.gravitino.client.GravitinoMetalake;
+import org.apache.gravitino.flink.connector.store.GravitinoCatalogStoreFactoryOptions;
+import org.apache.gravitino.integration.test.util.BaseIT;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+/**
+ * End-to-end integration test for Flink Basic authentication against the built-in IdP. Exercises
+ * the full path: Flink catalog store → HTTP Basic credentials → Gravitino REST → built-in IdP
+ * validation.
+ */
+public class FlinkBasicAuthIT extends BaseIT {
+
+ private static final String METALAKE = "flink_basic_auth";
+ private static final String ADMIN = "admin";
+ private static final String ADMIN_PASSWORD = "Passw0rd-For-Admin1";
+ private static final String IDP_REST_EXTENSION_PACKAGE =
+ "org.apache.gravitino.idp.web.rest.feature";
+
+ private static String gravitinoUri;
+
+ private static TableEnvironment tableEnv;
+
+ @BeforeAll
+ @Override
+ public void startIntegrationTest() throws Exception {
+ setEnv("GRAVITINO_INITIAL_ADMIN_PASSWORD", ADMIN_PASSWORD);
+ Map<String, String> configs = Maps.newHashMap();
+ configs.put(Configs.ENABLE_AUTHORIZATION.getKey(), String.valueOf(false));
+ configs.put(Configs.CACHE_ENABLED.getKey(), String.valueOf(false));
+ configs.put(Configs.SERVICE_ADMINS.getKey(), ADMIN);
+ configs.put(Configs.REST_API_EXTENSION_PACKAGES.getKey(), IDP_REST_EXTENSION_PACKAGE);
+ registerCustomConfigs(configs);
+ super.startIntegrationTest();
+
+ gravitinoUri = String.format("http://127.0.0.1:%d", getGravitinoServerPort());
+ try (GravitinoAdminClient adminClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ adminClient.createMetalake(METALAKE, "Flink basic auth test metalake", Maps.newHashMap());
+ }
+
+ Configuration configuration = new Configuration();
+ configuration.setString(
+ "table.catalog-store.kind", GravitinoCatalogStoreFactoryOptions.GRAVITINO);
+ configuration.setString("table.catalog-store.gravitino.gravitino.metalake", METALAKE);
+ configuration.setString("table.catalog-store.gravitino.gravitino.uri", gravitinoUri);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.AUTH_TYPE,
+ GravitinoCatalogStoreFactoryOptions.BASIC);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME,
+ ADMIN);
+ configuration.setString(
+ "table.catalog-store.gravitino." + GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD,
+ ADMIN_PASSWORD);
+
+ EnvironmentSettings.Builder builder =
+ EnvironmentSettings.newInstance().withConfiguration(configuration);
+ tableEnv = TableEnvironment.create(builder.inBatchMode().build());
+ }
+
+ @AfterAll
+ @Override
+ public void stopIntegrationTest() throws IOException, InterruptedException {
+ if (tableEnv != null) {
+ try {
+ TableEnvironmentImpl env = (TableEnvironmentImpl) tableEnv;
+ env.getCatalogManager().close();
+ } catch (Exception e) {
+ throw new RuntimeException("Failed to close Flink table environment", e);
+ }
+ }
+ super.stopIntegrationTest();
+ }
+
+ @Test
+ public void testFlinkConnectsWithBasicAuth() {
+ Assertions.assertDoesNotThrow(() -> tableEnv.executeSql("SHOW CATALOGS").print());
+
+ try (GravitinoAdminClient basicClient =
+ GravitinoAdminClient.builder(gravitinoUri).withBasicAuth(ADMIN, ADMIN_PASSWORD).build()) {
+ GravitinoMetalake loadedMetalake = basicClient.loadMetalake(METALAKE);
+ Assertions.assertEquals(METALAKE, loadedMetalake.name());
Review Comment:
What I mean is that simply verifying that SHOW CATALOGS does not throw an exception cannot validate your change. If this is the way you are testing it, it would be better to add an integration test to verify the basic authentication between the Gravitino client and the Gravitino server.
If this integration test is in place, you can add unit tests to ensure the connector configuration is processed correctly. and remove the integration tests for those connectors. Manual verification is also acceptable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [#11443] feat(auth): Add Basic auth support for Spark, Flink, and Trino connectors [gravitino]
Posted by "roryqi (via GitHub)" <gi...@apache.org>.
roryqi commented on code in PR #11457:
URL: https://github.com/apache/gravitino/pull/11457#discussion_r3369051481
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/GravitinoCatalogManager.java:
##########
@@ -244,6 +247,37 @@ private static boolean checkEqual(
&& gravitinoCatalogManager.gravitinoClientConfig.equals(gravitinoClientConfig);
}
+ private static GravitinoAdminClient buildBasicClient(
+ String gravitinoUri, Map<String, String> config) {
+ String username = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME);
+ String password = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD);
+ if (Strings.isNullOrEmpty(username)) {
Review Comment:
StringUtils.
##########
trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/security/GravitinoAuthProvider.java:
##########
@@ -230,6 +245,21 @@ private static void buildSimpleAuth(
}
}
+ private static void buildBasicAuth(
+ GravitinoAdminClient.AdminClientBuilder builder, Map<String, String> config) {
+ String username = config.get(BASIC_USERNAME_KEY);
+ String password = config.get(BASIC_PASSWORD_KEY);
+ if (StringUtils.isBlank(username)) {
Review Comment:
Preconditions.
##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/catalog/GravitinoCatalogManager.java:
##########
@@ -244,6 +247,37 @@ private static boolean checkEqual(
&& gravitinoCatalogManager.gravitinoClientConfig.equals(gravitinoClientConfig);
}
+ private static GravitinoAdminClient buildBasicClient(
+ String gravitinoUri, Map<String, String> config) {
+ String username = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_USERNAME);
+ String password = config.get(GravitinoCatalogStoreFactoryOptions.BASIC_PASSWORD);
+ if (Strings.isNullOrEmpty(username)) {
+ throw new IllegalArgumentException(
Review Comment:
Preconditions.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@gravitino.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org