HIVE-29020: Support OAuth 2 in Iceberg REST Catalog#6086
HIVE-29020: Support OAuth 2 in Iceberg REST Catalog#6086okumin merged 4 commits intoapache:masterfrom
Conversation
@check-spelling-bot Report🔴 Please reviewSee the files view or the action log for details. Unrecognized words (6)calcualtion Previously acknowledged words that are now absentwwwTo accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands... in a clone of the git@github.com:okumin/hive.git repository If the flagged items do not appear to be textIf items relate to a ...
|
| } | ||
|
|
||
| enum Route { | ||
| TOKENS(HTTPMethod.POST, "v1/oauth/tokens", null), |
There was a problem hiding this comment.
The initial specification of Iceberg REST allows the Iceberg REST Catalog to act as an Authorization Server, which is why the list contains this endpoint. As this does not follow security best practices, it will be removed.
There was a problem hiding this comment.
It will be removed with Iceberg spec 2.0; at this point, it may be deprecated but should not be removed yet, should it ?
There was a problem hiding this comment.
Yes, it should.
The token endpoint is not of a Resource Server but of an Authorization Server, i.e., typically Identity Provider such as Keycloak or Okta. The token endpoint is responsible for issuing a secure(e.g., cryptographically signed) Access Token.
Our endpoint is just a copied and pasted from iceberg-core, which is almost like an echo server(no authentication happens). It is possible to embed the Authorization Server roles in HMS; however, we would need to implement an RFC 6749, RFC 9068, or another RFC-compliant Authorization Server in that case. Otherwise, no user exists(who wants OAuth 2 that allows unauthenticated access?).
| LOG.warn("Rejecting an expired JWT: {}", parsedJwt.getPayload()); | ||
| throw new AuthenticationException("JWT (ends with " + lastSevenChars + ") has been expired"); | ||
| } | ||
| public JWTValidator(Set<JOSEObjectType> acceptableTypes, List<URL> jwksURLs, String expectedIssuer, |
There was a problem hiding this comment.
I replaced our custom implementation, following the article below.
https://connect2id.com/products/nimbus-jose-jwt/examples/validating-jwt-access-tokens
| .withEnv("KEYCLOAK_ADMIN","admin") | ||
| .withEnv("KEYCLOAK_ADMIN_PASSWORD","admin") | ||
| .withCommand("start-dev") | ||
| .withExposedPorts(8080); |
There was a problem hiding this comment.
I initially tried to use spring-security-oauth2-authorization-server, but gave it up because it has a hard dependency conflict on spring-core derived from Apache Atlas, and Nimbus we're using.
ab519b9 to
b2ae59a
Compare
|
I'm testing this in my local, and going to add how-to-setup to hive-site. I will merge this after that |
|
henrib
left a comment
There was a problem hiding this comment.
Should we remove the oauth/tokens endpoint yet ?
| } | ||
|
|
||
| enum Route { | ||
| TOKENS(HTTPMethod.POST, "v1/oauth/tokens", null), |
There was a problem hiding this comment.
It will be removed with Iceberg spec 2.0; at this point, it may be deprecated but should not be removed yet, should it ?
|
@deniskuzZ @henrib Thanks for your reviews! |
* HIVE-29020: Support OAuth 2 in Iceberg REST Catalog * Apply some review comments * Rephrase some configurations * Normalize the var name of CATALOG_SERVLET_AUTH_OAUTH2_PRINCIPAL_MAPPER_REGEX_FIELD



What changes were proposed in this pull request?
Add RFC 7662 or RFC 9068-based OAuth 2 support.
https://issues.apache.org/jira/browse/HIVE-29020
Why are the changes needed?
OAuth 2 is the most common authorization method for protecting the Iceberg REST Catalog. As the Iceberg library officially supports it, Iceberg users would be able to use it without custom patches if we were to support it. Additionally, OAuth 2 is an industry-standard protocol as of 2025.
The security principles and considerations are written in the following document.
https://docs.google.com/document/d/1wOlmpKP4jZb4Je67wusdMoQ4VWgGfi5JLe8w3MP5mpE/edit?usp=sharing
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added integration tests.