livery_s3_sigv4 (livery_s3 v0.1.0)
View SourceAWS Signature Version 4 for S3, as a livery_client layer.
Used two ways:
- As the innermost client layer (
call/3): it derives the payload hash, setshost/x-amz-date/x-amz-content-sha256(andx-amz-security-tokenwhen a session token is configured), signshostplus everyx-amz-*header, and adds theauthorizationheader before handing the request to the transport. - As a presigner (
presigned_url/8): query-string signing for time-limited GET/PUT URLs, withUNSIGNED-PAYLOADandhostas the only signed header.
The pure authorization/1 primitive computes a signature from explicit inputs;
it is exercised against AWS's published S3 worked examples in the tests.
Summary
Functions
Compute the Authorization header value from explicit, already-canonical
inputs. headers is the exact set to sign; path/query are the canonical URI
and query string; payload_hash is the hex SHA-256 (or UNSIGNED-PAYLOAD).
Sign the request, then hand it to the next layer.
Return the current {amz-datetime, yyyymmdd} pair in UTC.
Build a presigned URL (query-string SigV4) with explicitly-resolved Creds.
ExtraQuery holds operation params (e.g. versionId); they are signed alongside
the X-Amz-* auth params. Only the host header is signed and the payload is
UNSIGNED-PAYLOAD.
Types
Functions
-spec authorization(sign_input()) -> binary().
Compute the Authorization header value from explicit, already-canonical
inputs. headers is the exact set to sign; path/query are the canonical URI
and query string; payload_hash is the hex SHA-256 (or UNSIGNED-PAYLOAD).
-spec call(livery_client:request(), livery_client:next(), #s3_config{scheme :: binary(), host :: binary(), port :: undefined | inet:port_number(), region :: binary(), credentials :: livery_s3_credentials:handle(), addressing :: path | virtual}) -> livery_client:result().
Sign the request, then hand it to the next layer.
Return the current {amz-datetime, yyyymmdd} pair in UTC.
-spec presigned_url(#s3_config{scheme :: binary(), host :: binary(), port :: undefined | inet:port_number(), region :: binary(), credentials :: livery_s3_credentials:handle(), addressing :: path | virtual}, livery_s3_credentials:creds(), atom() | binary(), binary(), binary(), pos_integer(), [{binary(), binary()}], {binary(), binary()}) -> binary().
Build a presigned URL (query-string SigV4) with explicitly-resolved Creds.
ExtraQuery holds operation params (e.g. versionId); they are signed alongside
the X-Amz-* auth params. Only the host header is signed and the payload is
UNSIGNED-PAYLOAD.