ExStorageServiceSdk.SigV4 (ex_storage_service_sdk v0.7.1)

Copy Markdown View Source

AWS Signature V4 client-side request signing.

Signs outgoing HTTP requests with the standard AWS SigV4 algorithm. This is the client-side counterpart to the server's SigV4 verification.

Summary

Functions

Generates a presigned URL for the given parameters.

Signs an HTTP request and returns the headers to add.

Functions

presign_url(method, url, opts)

@spec presign_url(String.t(), String.t(), keyword()) :: String.t()

Generates a presigned URL for the given parameters.

Parameters

  • method - HTTP method
  • url - Base URL, including any existing query pairs
  • opts - Options:
    • :access_key_id - required
    • :secret_access_key - required
    • :region - default "us-east-1"
    • :expires - seconds until expiry (default 3600)
    • :now - override time for testing
    • :session_token - Temporary credential token

sign_headers(method, url, headers, body, opts)

@spec sign_headers(
  String.t(),
  String.t(),
  [{String.t(), String.t()}],
  binary(),
  keyword()
) :: [
  {String.t(), String.t()}
]

Signs an HTTP request and returns the headers to add.

Parameters

  • method - HTTP method (e.g., "GET", "PUT")
  • url - Full URL string
  • headers - Existing headers as a keyword list or map
  • body - Request body (binary or "" for GET)
  • opts - Options:
    • :access_key_id - AWS access key ID (required)
    • :secret_access_key - AWS secret access key (required)
    • :region - AWS region (default: "us-east-1")
    • :service - AWS service name (default: "s3")
    • :now - Override current time (for testing)
    • :payload_hash - Precomputed SHA256 hex or UNSIGNED-PAYLOAD for streamed bodies
    • :session_token - Temporary credential token

Returns

A list of header tuples to merge into the request.