ExStorageServiceCli.SigV4 (ex_storage_service_cli v0.1.3)

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 (without query params)
  • 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

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)

Returns

A list of header tuples to merge into the request.