← 一覧へ

HMACと自動UTC日付でストレージへの署名付きリクエストを実現

原題: Sign storage requests with HMAC and automatic UTC dates

changelog / Storage / Rules / 2026/11/27 09:00 JST

signrequestsautomatic

要約

CloudflareのRules言語にHMAC署名、SigV4鍵導出、UTC日付整形の関数が加わり、非公開のAmazon S3やGoogle Cloud Storageバケットへの読み取りを、Request Header Transform Rulesだけで認証できるようになった。hmac_sha256などのダイジェスト関数と、署名鍵の導出から16進署名までを1回で済ませるsign_sigv4_hmac_sha256、タイムスタンプをx-amz-date形式に整えるformat_dateを組み合わせ、Authorizationヘッダーを動的に構築できる。HMAC・SigV4関数はPro以上のプラン、format_dateは全プランで利用可能。Workersを書かずに署名付きオリジンアクセスを実現できるため、S3をオリジンにするサイト運営者にとって実用的な機能追加だ。

RulesStorage 出典サイトのOGP画像 出典サイトで原文を開く →

出典サイトの説明: Use Rules language HMAC functions, a native SigV4 signer, and UTC date formatting to authenticate private storage origin requests.

The Rules language supports HMAC signing, Signature Version 4 (SigV4) key derivation, and UTC date formatting. Use these functions in Request Header Transform Rules to authenticate reads from private Amazon S3 and Google Cloud Storage buckets. hmac_md5() , hmac_sha1() , hmac_sha256() , and hmac_sha512() compute raw keyed digests. sign_sigv4_hmac_sha256() derives the signing key and returns the lowercase hexadecimal signature in one call. format_date() formats the request timestamp for date headers and credential scopes. encode_hex() converts raw digests to lowercase hexadecimal text. For example, set x-amz-date or x-goog-date dynamically using: format_date(http.request.timestamp.sec, “%Y%m%dT%H%M%SZ”) The same rule can build an Authorization header from that request timestamp. Callers do not need to supply a date header. You remain responsible for constructing the canonical request and string to sign. The HMAC and SigV4 signing functions are available on Pro, Business, and Enterprise plans. format_date() is available on all plans without an additional entitlement. Use it in URI, request header, and response header rewrite expressions, not rule filters. For complete expressions and

出典: 公式ページ

この記事をシェア