Skip to content

Commit e9d6537

Browse files
committed
fix(runtime): preserve SigV4 behind private Space auth
1 parent 911ba5e commit e9d6537

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎hfs/nginx.conf‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ http {
122122
proxy_http_version 1.1;
123123

124124
proxy_set_header Host $proxy_host_header;
125+
# The HF private-Space gateway consumes this header. Do not pass it
126+
# to MinIO, where an unsigned X-* header invalidates SigV4.
127+
proxy_set_header X-HF-Authorization "";
125128
proxy_set_header X-Real-IP $remote_addr;
126129
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
127130
proxy_set_header X-Forwarded-Proto $forwarded_proto;

‎scripts/smoke-s3-curl.sh‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ for required_curl_flag in '--aws-sigv4' '--fail-with-body'; do
7070
fi
7171
done
7272

73+
hf_gateway_args=()
74+
if [[ -n "${HF_GATEWAY_TOKEN:-}" ]]; then
75+
hf_gateway_args=(-H "X-HF-Authorization: Bearer ${HF_GATEWAY_TOKEN}")
76+
fi
77+
7378
tmp_dir="$(mktemp -d)"
7479
payload_file="$tmp_dir/payload.txt"
7580
signed_download="$tmp_dir/signed-download.txt"
@@ -83,13 +88,15 @@ policy_applied=0
8388

8489
signed_curl() {
8590
curl --silent --show-error --fail-with-body \
91+
"${hf_gateway_args[@]}" \
8692
--aws-sigv4 "aws:amz:${REGION}:s3" \
8793
--user "${ACCESS_KEY}:${SECRET_KEY}" \
8894
"$@"
8995
}
9096

9197
signed_status() {
9298
curl --silent --show-error \
99+
"${hf_gateway_args[@]}" \
93100
--aws-sigv4 "aws:amz:${REGION}:s3" \
94101
--user "${ACCESS_KEY}:${SECRET_KEY}" \
95102
-o "$status_body" \
@@ -156,7 +163,7 @@ if ! cmp -s "$payload_file" "$signed_download"; then
156163
fi
157164

158165
echo "==> anonymous read is denied before policy"
159-
private_status="$(curl --silent --show-error -o "$private_body" -w '%{http_code}' "$ENDPOINT/$BUCKET/$OBJECT" || true)"
166+
private_status="$(curl --silent --show-error "${hf_gateway_args[@]}" -o "$private_body" -w '%{http_code}' "$ENDPOINT/$BUCKET/$OBJECT" || true)"
160167
if [[ "$private_status" != "403" ]]; then
161168
echo "Expected anonymous read HTTP 403 before policy, got $private_status" >&2
162169
exit 1
@@ -167,7 +174,7 @@ signed_curl -X PUT -H 'Content-Type: application/json' --data-binary @"$policy_f
167174
policy_applied=1
168175

169176
echo "==> anonymous read succeeds after policy"
170-
curl --silent --show-error --fail-with-body "$ENDPOINT/$BUCKET/$OBJECT" -o "$public_download"
177+
curl --silent --show-error --fail-with-body "${hf_gateway_args[@]}" "$ENDPOINT/$BUCKET/$OBJECT" -o "$public_download"
171178
if ! cmp -s "$payload_file" "$public_download"; then
172179
echo "Public download content does not match uploaded payload." >&2
173180
exit 1

‎scripts/validate-contract.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ PY
199199
'
200200

201201
check "S3 smoke script contract" require_pattern scripts/smoke-s3-curl.sh '--aws-sigv4' 'S3 smoke test must use curl SigV4 support'
202+
require_pattern scripts/smoke-s3-curl.sh 'X-HF-Authorization: Bearer' 'private candidate S3 smoke must support separate HF gateway auth'
202203
require_pattern scripts/smoke-s3-curl.sh 'Refusing to use bucket' 'S3 smoke test must refuse existing buckets'
203204

204205
check "storage sampler script contract" test -f scripts/sample-hf-bucket-storage.sh
@@ -214,6 +215,7 @@ require_pattern hfs/nginx.conf 'location = /_admin' 'Nginx must normalize /_admi
214215
require_pattern hfs/nginx.conf 'proxy_pass http://127\.0\.0\.1:8082/;' 'Nginx must proxy admin service'
215216
require_pattern hfs/nginx.conf 'proxy_pass http://127\.0\.0\.1:9001/;' 'Console proxy_pass must strip /console/ prefix'
216217
require_pattern hfs/nginx.conf 'proxy_pass http://127\.0\.0\.1:9000;' 'S3 API must stay at the root path'
218+
require_pattern hfs/nginx.conf 'proxy_set_header X-HF-Authorization "";' 'S3 proxy must strip the private Space gateway header before SigV4 verification'
217219
require_pattern hfs/nginx.conf 'proxy_hide_header X-Frame-Options;' 'Console proxy must hide upstream X-Frame-Options'
218220

219221
check "ops/admin service contract" require_pattern hfs/ops_service.py 'SECRET_KEYS' 'ops service must summarize secret presence only'

0 commit comments

Comments
 (0)