diqiu50 commented on code in PR #11628:
URL: https://github.com/apache/gravitino/pull/11628#discussion_r3412766184


##########
flink-connector/flink-common/src/main/java/org/apache/gravitino/flink/connector/iceberg/GravitinoIcebergCatalogFactory.java:
##########
@@ -122,9 +139,78 @@ private Map<String, String> 
toIcebergCatalogOptions(Map<String, String> catalogO
         && 
!icebergCatalogOptions.containsKey(IcebergPropertiesConstants.ICEBERG_CATALOG_TYPE))
 {
       
icebergCatalogOptions.put(IcebergPropertiesConstants.ICEBERG_CATALOG_TYPE, 
catalogBackend);
     }
+    injectRestAuth(
+        icebergCatalogOptions,
+        catalogBackend,
+        GravitinoCatalogManager.get().getGravitinoClientConfig());
     // The outer Flink factory is `gravitino-iceberg`, but the nested Iceberg 
factory still expects
     // `catalog-type=iceberg` when building the native Iceberg catalog 
instance.
     icebergCatalogOptions.put(CommonCatalogOptions.CATALOG_TYPE.key(), 
"iceberg");
     return icebergCatalogOptions;
   }
+
+  /**
+   * Propagates the Gravitino client's authentication to the Iceberg REST 
catalog options. A REST
+   * backend connects directly to the Iceberg REST service, bypassing the 
Gravitino server's auth
+   * proxy, so the REST client needs its own credentials. Does nothing for 
non-REST backends, or
+   * when the user has already configured REST auth explicitly.
+   *
+   * @param icebergCatalogOptions the Iceberg catalog options to inject auth 
into
+   * @param catalogBackend the Gravitino Iceberg catalog backend (e.g. {@code 
rest}, {@code hive})
+   * @param gravitinoClientConfig the Gravitino client config carrying the 
authentication entries
+   */
+  @VisibleForTesting
+  static void injectRestAuth(
+      Map<String, String> icebergCatalogOptions,
+      String catalogBackend,
+      Map<String, String> gravitinoClientConfig) {
+    if 
(IcebergPropertiesConstants.ICEBERG_CATALOG_BACKEND_REST.equalsIgnoreCase(catalogBackend)
+        && !icebergCatalogOptions.containsKey(AuthProperties.AUTH_TYPE)) {
+      
icebergCatalogOptions.putAll(toRestAuthProperties(gravitinoClientConfig));
+    }

Review Comment:
   Not a issue



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to