[Cherry-pick to branch-1.3] Feature/trino connector oauth2 user forwarding (#12045) - #12698
Merged
diqiu50 merged 2 commits intoAug 31, 2026
Merged
Conversation
### Summary Adds per-user authorization and credential vending support to the Gravitino Trino connector for Iceberg catalogs backed by the Iceberg REST Catalog (IRC). Changes Two commits: * oauth2 per-user token forwarding — Extends the connector's session forwarding (forwardUser=true) to support authType=oauth2, not just simple. When enabled, the end user's forwarded IdP token is presented to the Gravitino server, so authorization runs against the real end user instead of a shared service identity. Adds StaticUserTokenProvider, widens the auth guards in GravitinoConnector and GravitinoAuthProvider, and keys the per-user client cache by auth type. * per-user credential vending for IRC-backed Iceberg — Configures the generated Trino Iceberg REST catalog so that an IRC-backed Gravitino catalog requests per-user, per-table vended credentials. Sets security=OAUTH2, session=USER, and vended-credentials-enabled=true, and maps the warehouse through, so Trino's Iceberg REST client forwards the end-user token to the IRC and obtains scoped storage credentials over the REST protocol. ### Testing Unit tests added for the oauth2 forwarding path (TestGravitinoAuthProvider) and the REST backend config mapping (TestIcebergCatalogPropertyConverter). End-to-end verification against a live IRC is in progress. ### Motivation Trino is a primary query engine for enterprise customers who require real per-user authorization and scoped credentials rather than a shared service identity. --------- Co-authored-by: Mark Hoerth <mark@datastrato.com> Co-authored-by: yuhui <hui@datastrato.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> (cherry picked from commit 16db87b)
Contributor
There was a problem hiding this comment.
Pull request overview
This cherry-pick extends the Gravitino Trino connector’s session user-forwarding support to authType=oauth2, enabling per-query authentication using the end user’s forwarded OAuth2 access token (when the Trino coordinator provides it). It also improves Iceberg REST-catalog property conversion and adds additional debug logging for authentication/cache behavior.
Changes:
- Add OAuth2-aware per-session client building and per-user session cache keying (including token rotation behavior).
- Introduce
StaticUserTokenProviderto present a forwarded end-user token directly to the Gravitino client. - Extend Iceberg REST backend property conversion (optional
warehouse) and expand docs/tests accordingly.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoConnector.java | Implements per-session metadata resolution for forwarded users, including token-aware cache keying and improved error mapping. |
| trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/security/GravitinoAuthProvider.java | Adds OAuth2 session-forwarding support (token extraction from extra-credentials) and config key for token credential name. |
| trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/security/StaticUserTokenProvider.java | New token provider that returns a pre-fetched user token for OAuth2 forwarding. |
| trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/catalog/iceberg/IcebergCatalogPropertyConverter.java | Adds optional warehouse propagation for REST-backed Iceberg catalogs. |
| trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/TestGravitinoConnectorForwardUser.java | Updates/expands tests to validate OAuth2 forwarding construction, cache key behavior, token rotation, and error mapping. |
| trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/security/TestGravitinoAuthProvider.java | Adds tests for OAuth2 buildForSession, custom credential key, and missing-token behavior. |
| trino-connector/trino-connector/src/test/java/org/apache/gravitino/trino/connector/catalog/iceberg/TestIcebergCatalogPropertyConverter.java | Adds REST-backend property conversion test coverage including optional warehouse and missing-uri case. |
| server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java | Adds debug logging for request URI/auth header presence/principal resolution. |
| iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/IcebergCatalogWrapperManager.java | Adds debug logging for catalog wrapper cache hit/miss. |
| docs/trino-connector/authentication.md | Documents OAuth2 session credential forwarding requirements/limitations and reorganizes auth sections. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+301
to
+305
| static String sessionCacheKey(String authType, String user, String token) { | ||
| String tokenPart = | ||
| StringUtils.isBlank(token) ? "" : ":" + Integer.toHexString(token.hashCode()); | ||
| return authType + ":" + user + tokenPart; | ||
| } |
Comment on lines
+81
to
+85
| Assertions.assertThrows( | ||
| TrinoException.class, | ||
| () -> propertyConverter.gravitinoToEngineProperties(wrongMap), | ||
| "Missing required property for Rest backend: [uri]"); | ||
| } |
Comment on lines
+317
to
+319
| assertThrows( | ||
| TrinoException.class, () -> GravitinoAuthProvider.buildForSession(config, session)); | ||
| } |
Code Coverage Report
Files
|
…o-branch-1.3 # Conflicts: # trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/GravitinoConnector.java # trino-connector/trino-connector/src/main/java/org/apache/gravitino/trino/connector/security/GravitinoAuthProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick Information:
branch-1.3