You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by "danhuawang (via GitHub)" <gi...@apache.org> on 2026/06/11 09:28:00 UTC

[I] [Bug report] Flink Iceberg connector (REST backend) fails to authenticate against IRC when auth is enabled [gravitino]

danhuawang opened a new issue, #11601:
URL: https://github.com/apache/gravitino/issues/11601

   ### Version
   
   main branch
   
   ### Describe what's wrong
   
   When the Gravitino Iceberg REST Catalog (IRC) service has authentication enabled, the Flink connector fails with `NotAuthorizedException` when opening an Iceberg catalog with `catalog-backend=rest`. The user has already authenticated to Gravitino via OAuth2 through the Flink catalog store, but `GravitinoIcebergCatalog.open()` builds a native Iceberg `RESTCatalog` client that connects directly to the IRC endpoint without carrying any authentication credentials.
   
   The architecture issue: the connector bypasses the Gravitino server's auth proxy and makes the Flink client talk directly to IRC. Since IRC shares the same auth enforcement as Gravitino, the unauthenticated REST client is rejected. Users should not need to manually configure IRC authentication properties (e.g. `rest.auth.type`, `rest.auth.basic.username`) in the Gravitino catalog — Gravitino is the unified entry point and should transparently handle authentication propagation to its own IRC service.
   
   This is distinct from #11596 (JDBC backend `catalog-type` mapping issue). Here the `catalog-type=rest` is correctly recognized by Iceberg's `FlinkCatalogFactory`, but the resulting REST client lacks authentication credentials.
   
   ### Error message and/or stacktrace
   
   ```
   org.apache.iceberg.exceptions.NotAuthorizedException: Not authorized: The provided credentials did not support
       at org.apache.iceberg.rest.ErrorHandlers$DefaultErrorHandler.accept(ErrorHandlers.java:343)
       at org.apache.iceberg.rest.ErrorHandlers$ConfigErrorHandler.accept(ErrorHandlers.java:313)
       at org.apache.iceberg.rest.HTTPClient.throwFailure(HTTPClient.java:242)
       at org.apache.iceberg.rest.HTTPClient.execute(HTTPClient.java:347)
       at org.apache.iceberg.rest.BaseHTTPClient.get(BaseHTTPClient.java:77)
       at org.apache.iceberg.rest.RESTSessionCatalog.fetchConfig(RESTSessionCatalog.java:1337)
       at org.apache.iceberg.rest.RESTSessionCatalog.initialize(RESTSessionCatalog.java:211)
       at org.apache.iceberg.rest.RESTCatalog.initialize(RESTCatalog.java:96)
       at org.apache.iceberg.CatalogUtil.loadCatalog(CatalogUtil.java:295)
       at org.apache.iceberg.flink.CatalogLoader$RESTCatalogLoader.loadCatalog(CatalogLoader.java:163)
       at org.apache.iceberg.flink.FlinkCatalog.<init>(FlinkCatalog.java:119)
       at org.apache.iceberg.flink.FlinkCatalogFactory.createCatalog(FlinkCatalogFactory.java:166)
       at org.apache.gravitino.flink.connector.iceberg.GravitinoIcebergCatalog.open(GravitinoIcebergCatalog.java:98)
       at org.apache.flink.table.catalog.CatalogManager.setCurrentCatalog(CatalogManager.java:458)
       at org.apache.flink.table.api.internal.TableEnvironmentImpl.useCatalog(TableEnvironmentImpl.java:1222)
   ```
   
   ### How to reproduce
   
   + Gravitino version: main branch
   + Deploy Gravitino with IRC enabled and authentication enforced (OAuth2 or Basic auth):
     ```properties
     gravitino.iceberg-rest.catalog-config-provider = dynamic-config-provider
     gravitino.iceberg-rest.gravitino-uri = <gravitino-uri>
     gravitino.iceberg-rest.gravitino-metalake = test
     gravitino.iceberg-rest.default-catalog-name = catalog_1
     ```
   + Create an Iceberg catalog in Gravitino with `catalog-backend=rest` and `uri=<IRC endpoint>`.
   + Configure a Flink `TableEnvironment` with `table.catalog-store.kind=gravitino` and OAuth2 credentials (the user is fully authenticated to Gravitino).
   + Execute `USE CATALOG <iceberg_rest_catalog>;` — this triggers `GravitinoIcebergCatalog.open()`.
   + Observe `NotAuthorizedException: Not authorized: The provided credentials did not support`.
   
   ### Additional context
   
   The root cause is in `GravitinoIcebergCatalog.open()`: it constructs a native Iceberg `RESTCatalog` via `FlinkCatalogFactory.createCatalog()` using only the catalog properties stored in Gravitino (uri, io-impl, S3 config, etc.). No authentication properties (`rest.auth.type`, OAuth2 token, or bearer token) are injected into the Iceberg REST client properties.
   
   Expected behavior: Since the user has already authenticated to Gravitino (via the catalog store's OAuth2 config), the Flink connector should either:
   1. Propagate the user's OAuth2 token to the Iceberg REST client (e.g. set `rest.auth.type=oauth2` + token), or
   2. Route data-plane operations through the Gravitino server rather than having the Flink client connect directly to IRC.
   
   No other catalog type (Paimon, Hive) requires the user to manually configure backend-service authentication in `createCatalog` properties — this should be transparent. Related: #11596.
   


-- 
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.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [I] [Bug report] Flink Iceberg connector (REST backend) fails to authenticate against IRC when auth is enabled [gravitino]

Posted by "mchades (via GitHub)" <gi...@apache.org>.
mchades closed issue #11601: [Bug report] Flink Iceberg connector (REST backend) fails to authenticate against IRC when auth is enabled
URL: https://github.com/apache/gravitino/issues/11601


-- 
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: [I] [Bug report] Flink Iceberg connector (REST backend) fails to authenticate against IRC when auth is enabled [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on issue #11601:
URL: https://github.com/apache/gravitino/issues/11601#issuecomment-4718685105

   Re-opening visibility: the fix from #11628 does **not** take effect on the most common path — loading an already-persisted catalog through the Gravitino catalog store (`USE CATALOG ...`). It still fails with the same `NotAuthorizedException` at `RESTSessionCatalog.fetchConfig` (`GET /v1/config`).
   
   ### Root cause: the REST auth-propagation branch is gated on a key that has already been renamed
   
   In `GravitinoIcebergCatalogFactory.toIcebergCatalogOptions`, the auth propagation is gated on `catalog-backend`:
   
   ```java
   String catalogBackend =
       catalogOptions.get(IcebergPropertiesConstants.GRAVITINO_ICEBERG_CATALOG_BACKEND); // "catalog-backend"
   ...
   if (IcebergPropertiesConstants.ICEBERG_CATALOG_BACKEND_REST.equalsIgnoreCase(catalogBackend)
       && !icebergCatalogOptions.containsKey(AuthProperties.AUTH_TYPE)) {
     icebergCatalogOptions.putAll(
         IcebergPropertiesConverter.INSTANCE.toRestAuthProperties(
             GravitinoCatalogManager.get().getGravitinoClientConfig()));
   }
   ```
   
   But when a catalog is loaded via the catalog store, `GravitinoCatalogStore.getCatalog` runs `IcebergPropertiesConverter.toFlinkCatalogProperties(...)` first, which renames `catalog-backend` → `catalog-type`:
   
   ```java
   private static final Map<String, String> GRAVITINO_CONFIG_TO_FLINK_ICEBERG =
       ImmutableMap.of(IcebergConstants.CATALOG_BACKEND,            // "catalog-backend"
                       IcebergPropertiesConstants.ICEBERG_CATALOG_TYPE); // "catalog-type"
   ```
   
   So by the time the factory runs, the descriptor carries `catalog-type=rest` and **no** `catalog-backend` key. As a result:
   
   - `catalogBackend = options.get("catalog-backend")` → `null`
   - `"rest".equalsIgnoreCase(null)` → `false` → **auth propagation is skipped**
   - the catalog is still created as REST (the later branch reads `catalog-type`), but with no `rest.auth.*` → REST client hits `/v1/config` unauthenticated → 401.
   
   The two backend checks in the same method are inconsistent: the JDBC branch reads `catalog-type`, while the REST-auth branch reads `catalog-backend`.
   
   ### Why it slipped through
   
   - `TestGravitinoIcebergCatalogFactory.testRestBackendKeepsCatalogType` feeds the option as `catalog-type` and does **not** assert any auth property, so the propagation gap isn't exercised.
   - `CREATE CATALOG ... WITH ('catalog-backend'='rest', ...)` does carry `catalog-backend` in `context.getOptions()`, so that path works. The failure is specific to loading a persisted catalog through the catalog store — which is what the OAuth2 REST e2e test (and real users) do.
   
   ### Suggested fix
   
   Gate the REST auth propagation on the normalized `catalog-type` (after the `catalog-backend` → `catalog-type` normalization), so both the CREATE path and the catalog-store load path behave the same:
   
   ```java
   String catalogType = icebergCatalogOptions.get(IcebergPropertiesConstants.ICEBERG_CATALOG_TYPE);
   if (IcebergPropertiesConstants.ICEBERG_CATALOG_BACKEND_REST.equalsIgnoreCase(catalogType)
       && !icebergCatalogOptions.containsKey(AuthProperties.AUTH_TYPE)) {
     icebergCatalogOptions.putAll(
         IcebergPropertiesConverter.INSTANCE.toRestAuthProperties(
             GravitinoCatalogManager.get().getGravitinoClientConfig()));
   }
   ```
   
   A regression test should cover the catalog-store load path (`catalog-type=rest` with `gravitino.client.auth.type=oauth2`) and assert that `rest.auth.type` / OAuth2 properties are injected into the resulting Iceberg options.
   
   (Found while running an OAuth2 REST-backend Flink view e2e test on a branch that already includes #11628.)
   


-- 
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: [I] [Bug report] Flink Iceberg connector (REST backend) fails to authenticate against IRC when auth is enabled [gravitino]

Posted by "danhuawang (via GitHub)" <gi...@apache.org>.
danhuawang commented on issue #11601:
URL: https://github.com/apache/gravitino/issues/11601#issuecomment-4679129375

   @diqiu50 Could you help check this 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: commits-unsubscribe@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org