CTTY commented on code in PR #2660:
URL: https://github.com/apache/iceberg-rust/pull/2660#discussion_r3540157254
##########
crates/catalog/rest/src/catalog.rs:
##########
@@ -145,6 +159,12 @@ impl RestCatalogBuilder {
self.config.client = Some(client);
self
}
+
+ /// Injects a custom request signer, overriding the `rest.sigv4-*`
configuration.
+ pub fn with_signer(mut self, signer: Arc<dyn HttpRequestSigner>) -> Self {
Review Comment:
I think we need a more general design rather than just a signer. some
authentication mechanism is token-based.
##########
crates/catalog/rest/src/signing.rs:
##########
@@ -0,0 +1,448 @@
+// 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.
+
+use chrono::{DateTime, Utc};
+use iceberg::{Error, ErrorKind, Result};
+use reqsign_core::hash::{base64_encode, hex_hmac_sha256, hex_sha256,
hmac_sha256};
+use sha2::{Digest, Sha256};
+
+/// Hex SHA-256 of the empty string.
+const EMPTY_BODY_HEX_SHA256: &str =
+ "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
+
+/// How the payload hash is encoded in the `x-amz-content-sha256` header.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+pub enum PayloadHashMode {
+ /// Iceberg Java's RESTSigV4 style: base64 header for non-empty bodies, hex
+ /// for empty; the canonical request always uses hex.
+ IcebergRest,
+ /// Standard AWS SigV4 style: hex everywhere (e.g. AWS Glue).
+ StandardAws,
+}
Review Comment:
I didn't know this detail until this PR. Thanks for capturing this!
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]