HMAC署名とUTC日付の自動生成でストレージ要求に署名
原題: Sign storage requests with HMAC and automatic UTC dates
changelog / Storage / Rules / 2026/11/25 09:00 JST
CloudflareのRules言語に、HMAC署名とSigV4(Signature Version 4)の鍵導出、UTC日付の整形を行う関数が追加された。Request Header Transform Rulesの中で使い、非公開のAmazon S3やGoogle Cloud Storageバケットへの読み取り要求に認証を付けられる。hmac_sha256()などのダイジェスト関数に加え、sign_sigv4_hmac_sha256()が署名鍵の導出から16進署名の生成までを1回の呼び出しで済ませ、format_date()がx-amz-dateなどの日付ヘッダーや認証スコープ用のタイムスタンプを動的に作る。呼び出し側が日付ヘッダーを用意する必要はなく、正規要求と署名対象文字列の組み立ては利用者の責任のままとなる。HMACとSigV4関数はPro以上のプラン、format_date()は全プランで利用可能。プライベートなオリジンへのアクセスをエッジ側で署名できるようになり、署名付きURLの発行やオリジン保護の実装が一段と手軽になる。
出典サイトで原文を開く → 出典サイトの説明: 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
出典: 公式ページ