Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,10 @@ public enum ConfVars {
"The pattern to extract a user name. This is effective when you use RegexPrincipalMapper. For example, if " +
"you want to extract a user name from the local part of the email claim, set this to (.*)@example.com."
),
CATALOG_VENDED_CREDENTIALS_PROVIDERS("metastore.catalog.vended-credentials.providers",
"hive.metastore.catalog.vended-credentials.providers", "",
"List of comma-separated credential-vending provider IDs"
),
ICEBERG_CATALOG_SERVLET_PATH("metastore.iceberg.catalog.servlet.path",
"hive.metastore.iceberg.catalog.servlet.path", "iceberg",
"HMS Iceberg Catalog servlet path component of URL endpoint."
Expand All @@ -1982,6 +1986,10 @@ public enum ConfVars {
"hive.metastore.iceberg.catalog.unique.table.location", false,
"Whether the HMS Iceberg REST catalog should assign a unique storage location for each new table."
),
ICEBERG_CATALOG_VENDED_CREDENTIALS_ENABLED("metastore.iceberg.catalog.vended-credentials.enabled",
"hive.metastore.iceberg.catalog.vended-credentials.enabled", false,
"Boolean flag to enable credential vending on Iceberg REST Catalog"
),
ICEBERG_CATALOG_METRICS_REPORTERS("metastore.iceberg.catalog.metrics.reporters",
"hive.metastore.iceberg.catalog.metrics.reporters", "org.apache.iceberg.rest.metrics.LoggingMetricsReporter",
"A comma separated list of custom Iceberg Metrics Reporting plugins."
Expand Down
23 changes: 23 additions & 0 deletions standalone-metastore/metastore-rest-catalog/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
<log4j2.debug>false</log4j2.debug>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>${hive.version}</version>
<classifier>core</classifier>
<scope>provided</scope>
Comment on lines +34 to +39

@deniskuzZ deniskuzZ Apr 30, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest-catalog now depends on a hive-exec-core? scope was test-only before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, Hive's authorization framework is currently located in hive-exec.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, we should avoid hard coupling between HMS and HS2. is there some common place we could extract auth functionality?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially. I'd say it requires some strategic moves to decouple HMS and hive-exec. The authz framework is not the only dependency...
https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/optimizer/ppr/PartitionExpressionForMetastore.java

</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-standalone-metastore-server</artifactId>
Expand Down Expand Up @@ -84,6 +91,11 @@
<version>1.9.17</version>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bundle</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-standalone-metastore-common</artifactId>
Expand All @@ -105,6 +117,17 @@
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-aws</artifactId>
<version>${iceberg.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-aws</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.iceberg</groupId>
<artifactId>iceberg-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* 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.iceberg.rest;

/**
* Possible values for the X-Iceberg-Access-Delegation header.
*/
public enum AccessDelegationMode {
VENDED_CREDENTIALS, REMOTE_SIGNING
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletResponse;
import org.apache.iceberg.BaseTable;
import org.apache.iceberg.BaseTransaction;
Expand Down Expand Up @@ -82,7 +83,7 @@
import org.slf4j.LoggerFactory;

/**
* Original @ <a href="https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/test/java/org/apache/iceberg/rest/RESTCatalogAdapter.java">RESTCatalogAdapter.java</a>

Check warning on line 86 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Line is longer than 120 characters (found 179).

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pZ&open=AaDP0NqPcM05ZnmSf2pZ&pullRequest=6458
* Adaptor class to translate REST requests into {@link Catalog} API calls.
*/
public class HMSCatalogAdapter implements Closeable {
Expand Down Expand Up @@ -120,18 +121,20 @@
private final SupportsNamespaces asNamespaceCatalog;
private final ViewCatalog asViewCatalog;
private final IcebergAuthorizer icebergAuthorizer;
private final IcebergVendedCredentialProvider credentialProvider;
private final List<IcebergMetricsReporter> metricsReporters;
private final Clock clock = Clock.systemUTC();

public HMSCatalogAdapter(String catalogName, Catalog catalog, IcebergAuthorizer icebergAuthorizer,
List<IcebergMetricsReporter> metricsReporters) {
HMSCatalogAdapter(String catalogName, Catalog catalog, IcebergAuthorizer icebergAuthorizer,
IcebergVendedCredentialProvider credentialProvider, List<IcebergMetricsReporter> metricsReporters) {
Preconditions.checkArgument(catalog instanceof SupportsNamespaces);
Preconditions.checkArgument(catalog instanceof ViewCatalog);
this.catalogName = catalogName;
this.catalog = catalog;
this.asNamespaceCatalog = (SupportsNamespaces) catalog;
this.asViewCatalog = (ViewCatalog) catalog;
this.icebergAuthorizer = icebergAuthorizer;
this.credentialProvider = credentialProvider;
this.metricsReporters = metricsReporters;
}

Expand Down Expand Up @@ -239,7 +242,7 @@
int prefixLength = prefixLength(requestPath);

ImmutableMap.Builder<String, String> vars = ImmutableMap.builder();
for (Map.Entry<Integer, String> var : variables.entrySet()) {

Check warning on line 245 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this variable to not match a restricted identifier.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pY&open=AaDP0NqPcM05ZnmSf2pY&pullRequest=6458
vars.put(var.getValue(), requestPath.get(mappedIndex(var.getKey(), prefixLength)));
}

Expand Down Expand Up @@ -325,20 +328,23 @@
return castResponse(ListTablesResponse.class, CatalogHandlers.listTables(catalog, namespace));
}

private LoadTableResponse createTable(Map<String, String> vars, Object body) {
private LoadTableResponse createTable(Set<AccessDelegationMode> accessDelegationModes, Map<String, String> vars,
Object body) {
final Class<LoadTableResponse> responseType = LoadTableResponse.class;
Namespace namespace = namespaceFromPathVars(vars);
CreateTableRequest request = castRequest(CreateTableRequest.class, body);
request.validate();
LoadTableResponse response;
if (request.stageCreate()) {
Map<String, String> namespaceMetadata = asNamespaceCatalog.loadNamespaceMetadata(namespace);
icebergAuthorizer.validateStageCreateTable(catalogName, namespace, namespaceMetadata, request);
return castResponse(
responseType, CatalogHandlers.stageTableCreate(catalog, namespace, request));
response = castResponse(
responseType, CatalogHandlers.stageTableCreate(catalog, namespace, request));
} else {
return castResponse(
responseType, CatalogHandlers.createTable(catalog, namespace, request));
response = castResponse(
responseType, CatalogHandlers.createTable(catalog, namespace, request));
}
return withCredentials(accessDelegationModes, TableIdentifier.of(namespace, request.name()), response);
}

private RESTResponse dropTable(Map<String, String> vars) {
Expand All @@ -356,21 +362,33 @@
return null;
}

private LoadTableResponse loadTable(Map<String, String> vars) {
private LoadTableResponse loadTable(Set<AccessDelegationMode> delegationModes, Map<String, String> vars) {
TableIdentifier ident = identFromPathVars(vars);
return castResponse(LoadTableResponse.class, CatalogHandlers.loadTable(catalog, ident));
LoadTableResponse response =
castResponse(LoadTableResponse.class, CatalogHandlers.loadTable(catalog, ident));
return withCredentials(delegationModes, ident, response);
}

private LoadTableResponse registerTable(Map<String, String> vars, Object body) {
Namespace namespace = namespaceFromPathVars(vars);
RegisterTableRequest request = castRequest(RegisterTableRequest.class, body);
return castResponse(LoadTableResponse.class, CatalogHandlers.registerTable(catalog, namespace, request));
private LoadTableResponse registerTable(
Set<AccessDelegationMode> delegationModes,
Map<String, String> vars,
Object body) {
Namespace namespace = namespaceFromPathVars(vars);
RegisterTableRequest request = castRequest(RegisterTableRequest.class, body);
LoadTableResponse response =
castResponse(LoadTableResponse.class, CatalogHandlers.registerTable(catalog, namespace, request));
return withCredentials(delegationModes, TableIdentifier.of(namespace, request.name()), response);
}

private LoadTableResponse updateTable(Map<String, String> vars, Object body) {
private LoadTableResponse updateTable(
Set<AccessDelegationMode> delegationModes,
Map<String, String> vars,
Object body) {
TableIdentifier ident = identFromPathVars(vars);
UpdateTableRequest request = castRequest(UpdateTableRequest.class, body);
return castResponse(LoadTableResponse.class, CatalogHandlers.updateTable(catalog, ident, request));
LoadTableResponse response =
castResponse(LoadTableResponse.class, CatalogHandlers.updateTable(catalog, ident, request));
return withCredentials(delegationModes, ident, response);
}

private RESTResponse renameTable(Object body) {
Expand Down Expand Up @@ -450,6 +468,33 @@
LoadViewResponse.class, CatalogHandlers.registerView(asViewCatalog, namespace, request));
}

private LoadTableResponse withCredentials(
Set<AccessDelegationMode> accessDelegationModes,
TableIdentifier ident,
LoadTableResponse response) {
if (credentialProvider == null) {
return response;
}

if (accessDelegationModes.contains(AccessDelegationMode.VENDED_CREDENTIALS)) {
Comment thread
deniskuzZ marked this conversation as resolved.
return withVendedCredentials(ident, response);
}

if (accessDelegationModes.contains(AccessDelegationMode.REMOTE_SIGNING)) {
LOG.warn("Remote signing is not supported. Ignoring...");
}

return response;
}

private LoadTableResponse withVendedCredentials(TableIdentifier ident, LoadTableResponse response) {
final var credentials = credentialProvider.vend(catalogName, ident, response.tableMetadata());
return LoadTableResponse.builder()
.withTableMetadata(response.tableMetadata())
.addAllConfig(response.config())
.addAllCredentials(credentials).build();
}

/**
* This is a very simplistic approach that only validates the requirements for each table and does
* not do any other conflict detection. Therefore, it does not guarantee true transactional
Expand Down Expand Up @@ -481,39 +526,43 @@

@SuppressWarnings({"unchecked"})
private <T extends RESTResponse> T handleRequest(
Route route, Map<String, String> vars, Object body) {
Route route,
Set<AccessDelegationMode> accessDelegationModes,
Map<String, String> vars,
Object body) {
return (T) switch (route) {
case CONFIG -> config();

Check warning on line 534 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pa&open=AaDP0NqPcM05ZnmSf2pa&pullRequest=6458
case LIST_NAMESPACES -> listNamespaces(vars);

Check warning on line 535 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pb&open=AaDP0NqPcM05ZnmSf2pb&pullRequest=6458
case CREATE_NAMESPACE -> createNamespace(body);

Check warning on line 536 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pc&open=AaDP0NqPcM05ZnmSf2pc&pullRequest=6458
case NAMESPACE_EXISTS -> namespaceExists(vars);

Check warning on line 537 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pd&open=AaDP0NqPcM05ZnmSf2pd&pullRequest=6458
case LOAD_NAMESPACE -> loadNamespace(vars);

Check warning on line 538 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pe&open=AaDP0NqPcM05ZnmSf2pe&pullRequest=6458
case DROP_NAMESPACE -> dropNamespace(vars);

Check warning on line 539 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pf&open=AaDP0NqPcM05ZnmSf2pf&pullRequest=6458
case UPDATE_NAMESPACE -> updateNamespace(vars, body);

Check warning on line 540 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pg&open=AaDP0NqPcM05ZnmSf2pg&pullRequest=6458
case LIST_TABLES -> listTables(vars);

Check warning on line 541 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2ph&open=AaDP0NqPcM05ZnmSf2ph&pullRequest=6458
case CREATE_TABLE -> createTable(vars, body);
case CREATE_TABLE -> createTable(accessDelegationModes, vars, body);

Check warning on line 542 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pi&open=AaDP0NqPcM05ZnmSf2pi&pullRequest=6458
case DROP_TABLE -> dropTable(vars);

Check warning on line 543 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pj&open=AaDP0NqPcM05ZnmSf2pj&pullRequest=6458
case TABLE_EXISTS -> tableExists(vars);

Check warning on line 544 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pk&open=AaDP0NqPcM05ZnmSf2pk&pullRequest=6458
case LOAD_TABLE -> loadTable(vars);
case REGISTER_TABLE -> registerTable(vars, body);
case UPDATE_TABLE -> updateTable(vars, body);
case LOAD_TABLE -> loadTable(accessDelegationModes, vars);

Check warning on line 545 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pl&open=AaDP0NqPcM05ZnmSf2pl&pullRequest=6458
case REGISTER_TABLE -> registerTable(accessDelegationModes, vars, body);

Check warning on line 546 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pm&open=AaDP0NqPcM05ZnmSf2pm&pullRequest=6458
case UPDATE_TABLE -> updateTable(accessDelegationModes, vars, body);

Check warning on line 547 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pn&open=AaDP0NqPcM05ZnmSf2pn&pullRequest=6458
case RENAME_TABLE -> renameTable(body);

Check warning on line 548 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2po&open=AaDP0NqPcM05ZnmSf2po&pullRequest=6458
case REPORT_METRICS -> reportMetrics(vars, body);

Check warning on line 549 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pp&open=AaDP0NqPcM05ZnmSf2pp&pullRequest=6458
case COMMIT_TRANSACTION -> commitTransaction(body);

Check warning on line 550 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pq&open=AaDP0NqPcM05ZnmSf2pq&pullRequest=6458
case LIST_VIEWS -> listViews(vars);

Check warning on line 551 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pr&open=AaDP0NqPcM05ZnmSf2pr&pullRequest=6458
case CREATE_VIEW -> createView(vars, body);

Check warning on line 552 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2ps&open=AaDP0NqPcM05ZnmSf2ps&pullRequest=6458
case VIEW_EXISTS -> viewExists(vars);

Check warning on line 553 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pt&open=AaDP0NqPcM05ZnmSf2pt&pullRequest=6458
case LOAD_VIEW -> loadView(vars);

Check warning on line 554 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pu&open=AaDP0NqPcM05ZnmSf2pu&pullRequest=6458
case UPDATE_VIEW -> updateView(vars, body);

Check warning on line 555 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pv&open=AaDP0NqPcM05ZnmSf2pv&pullRequest=6458
case RENAME_VIEW -> renameView(body);

Check warning on line 556 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2pw&open=AaDP0NqPcM05ZnmSf2pw&pullRequest=6458
case DROP_VIEW -> dropView(vars);

Check warning on line 557 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2px&open=AaDP0NqPcM05ZnmSf2px&pullRequest=6458
case REGISTER_VIEW -> registerView(vars, body);

Check warning on line 558 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 6, expected level should be 4.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NqPcM05ZnmSf2py&open=AaDP0NqPcM05ZnmSf2py&pullRequest=6458
};
}

<T extends RESTResponse> T execute(
HTTPMethod method,
String path,
Set<AccessDelegationMode> accessDelegationModes,
Map<String, String> queryParams,
Object body,
HttpServletResponse response) throws IOException {
Expand All @@ -526,7 +575,7 @@
vars.putAll(queryParams);
}
vars.putAll(routeAndVars.second());
return handleRequest(routeAndVars.first(), vars.build(), body);
return handleRequest(routeAndVars.first(), accessDelegationModes, vars.build(), body);
} catch (RuntimeException e) {
configureResponseFromException(e, errorBuilder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,12 @@ private HttpServlet createServlet(Catalog catalog) {
ServletSecurity security = new ServletSecurity(AuthType.fromString(authType), configuration, req -> scopes);
String catalogName = MetastoreConf.getVar(configuration, ConfVars.CATALOG_DEFAULT);
IcebergAuthorizer icebergAuthorizer = new IcebergAuthorizer(configuration);
IcebergVendedCredentialProvider vendedCredentialProvider = null;
if (MetastoreConf.getBoolVar(configuration, ConfVars.ICEBERG_CATALOG_VENDED_CREDENTIALS_ENABLED)) {
vendedCredentialProvider = new IcebergVendedCredentialProvider(icebergAuthorizer, configuration);
}
List<IcebergMetricsReporter> reporters = createReporters();
var adapter = new HMSCatalogAdapter(catalogName, catalog, icebergAuthorizer, reporters);
var adapter = new HMSCatalogAdapter(catalogName, catalog, icebergAuthorizer, vendedCredentialProvider, reporters);
return security.proxy(new HMSCatalogServlet(adapter));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
package org.apache.iceberg.rest;

import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -35,7 +38,7 @@
import org.slf4j.LoggerFactory;

/**
* Original @ <a href="https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/test/java/org/apache/iceberg/rest/RESTCatalogServlet.java">RESTCatalogServlet.java</a>

Check warning on line 41 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Line is longer than 120 characters (found 179).

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDP0NojcM05ZnmSf2pX&open=AaDP0NojcM05ZnmSf2pX&pullRequest=6458
* The RESTCatalogServlet provides a servlet implementation used in combination with a
* RESTCatalogAdaptor to proxy the REST Spec to any Catalog implementation.
*/
Expand All @@ -43,7 +46,7 @@
private static final Logger LOG = LoggerFactory.getLogger(HMSCatalogServlet.class);
private static final String CONTENT_TYPE = "Content-Type";
private static final String APPLICATION_JSON = "application/json";

private final HMSCatalogAdapter restCatalogAdapter;
private final Map<String, String> responseHeaders =
ImmutableMap.of(CONTENT_TYPE, APPLICATION_JSON);
Expand Down Expand Up @@ -73,6 +76,7 @@
restCatalogAdapter.execute(
context.method(),
context.path(),
context.accessDelegationModes(),
context.queryParams(),
context.body(),
response);
Expand All @@ -95,6 +99,7 @@
public static class ServletRequestContext {
private HTTPMethod method;
private String path;
private Set<AccessDelegationMode> accessDelegationModes;
private Map<String, String> queryParams;
private Object body;

Expand All @@ -107,10 +112,12 @@
private ServletRequestContext(
HTTPMethod method,
String path,
Set<AccessDelegationMode> accessDelegationModes,
Map<String, String> queryParams,
Object body) {
this.method = method;
this.path = path;
this.accessDelegationModes = accessDelegationModes;
this.queryParams = queryParams;
this.body = body;
}
Expand All @@ -136,6 +143,21 @@
.build());
}

var accessDelegationModes = Arrays
.stream(Optional.ofNullable(request.getHeader("X-Iceberg-Access-Delegation")).orElse("").split(","))
.map(String::trim)
.filter(header -> !header.isEmpty())
.map(header -> switch (header) {
case "vended-credentials" -> AccessDelegationMode.VENDED_CREDENTIALS;

Check warning on line 151 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDJnyn5mX3Yz3mMtXhO&open=AaDJnyn5mX3Yz3mMtXhO&pullRequest=6458
case "remote-signing" -> AccessDelegationMode.REMOTE_SIGNING;

Check warning on line 152 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDJnyn5mX3Yz3mMtXhP&open=AaDJnyn5mX3Yz3mMtXhP&pullRequest=6458
default -> {

Check warning on line 153 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'case' child has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDJnyn5mX3Yz3mMtXhQ&open=AaDJnyn5mX3Yz3mMtXhQ&pullRequest=6458
LOG.warn("Unknown access delegation mode: {}", header);

Check warning on line 154 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'block' child has incorrect indentation level 14, expected level should be 12.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDJnyn5mX3Yz3mMtXhR&open=AaDJnyn5mX3Yz3mMtXhR&pullRequest=6458
Comment thread
deniskuzZ marked this conversation as resolved.
yield null;

Check warning on line 155 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'yield' has incorrect indentation level 14, expected level should be 12.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDJnyn5mX3Yz3mMtXhS&open=AaDJnyn5mX3Yz3mMtXhS&pullRequest=6458
}

Check warning on line 156 in standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogServlet.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'block rcurly' has incorrect indentation level 12, expected level should be 10.

See more on https://sonarcloud.io/project/issues?id=apache_hive&issues=AaDJnyn5mX3Yz3mMtXhT&open=AaDJnyn5mX3Yz3mMtXhT&pullRequest=6458
})
.filter(Objects::nonNull)
.collect(Collectors.toUnmodifiableSet());

Route route = routeContext.first();
Object requestBody = null;
if (route.requestClass() != null) {
Expand All @@ -154,7 +176,7 @@
request.getParameterMap().entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue()[0]));

return new ServletRequestContext(method, path, queryParams, requestBody);
return new ServletRequestContext(method, path, accessDelegationModes, queryParams, requestBody);
}

HTTPMethod method() {
Expand All @@ -165,6 +187,10 @@
return path;
}

public Set<AccessDelegationMode> accessDelegationModes() {
return accessDelegationModes;
}

public Map<String, String> queryParams() {
return queryParams;
}
Expand Down
Loading
Loading