plug_signature v0.8.0 PlugSignature.ConnTest View Source

Helpers for testing HTTP signatures with Plug/Phoenix.

Link to this section Summary

Functions

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Makes a signed request to a Phoenix endpoint.

Add an HTTP Digest header (RFC3230, section 4.3.2).

Adds an Authorization header with a signature. Requires a secret (RSA private key, EC private key or HMAC shared secret) and key ID.

Link to this section Functions

Link to this macro

signed_connect(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_delete(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_get(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_head(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_options(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_patch(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_post(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_put(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this macro

signed_trace(conn, path, params_or_body \\ nil, sign_opts)

View Source (macro)

Makes a signed request to a Phoenix endpoint.

The last argument is a keyword list with signature options, with the :key and :key_id options being mandatory. For other options, please see with_signature/4.

Requires Phoenix.ConnTest.

Link to this function

with_digest(conn, body_or_digests)

View Source
This function is deprecated. Use PlugBodyDigest.ConnTest.with_digest/2, from the plug_body_digest package.

Add an HTTP Digest header (RFC3230, section 4.3.2).

When the request body is passed in as a binary, a SHA-256 digest of the body is calculated and added as part of the header. Alternatively, a map of digest types and values may be provided.

Link to this function

with_signature(conn, key, key_id, opts \\ [])

View Source

Adds an Authorization header with a signature. Requires a secret (RSA private key, EC private key or HMAC shared secret) and key ID.

Options

  • :algorithms - the HTTP signature algorithms to be used; list with one or more of:

    • "hs2019" (default)
    • "rsa-sha256"
    • "rsa-sha1"
    • "ecdsa-sha256"
    • "hmac-sha256"

    The first algorithm in the list will be used to generate the signature (it is a list to allow the core set of configuration options to be shared with PlugSignature in tests).

  • :headers - set the list of HTTP (pseudo) headers to sign; defaults to "(created)" (which is only valid when the algorithm is "hs2019")

  • :request_target - explicitly set the request target; by default it is built from the Plug.Conn struct (method, request_path and query)

  • :age - shift the HTTP Date header and the signature's 'created' parameter by the given number of seconds into the past; defaults to 0

  • :created - set the signature's 'created' parameter (overrides :age); set to a empty string to omit the 'created' parameter

  • :date - set the HTTP Date header (overrides :age)

  • :expires_in - if set, adds an 'expires' parameter with a timestamp the given number of seconds in the future

  • :expires - set the signature's 'expires' parameter (overrides :expires_in)

  • :key_id_override - override the value for keyId in the Authorization header

  • :algorithm_override - override the value for the signature's 'algorithm' parameter in the Authorization header

  • :signature_override - override the signature value sent in the Authorization header

  • :headers_override - override the value for the signature's 'headers' parameter in the Authorization header

  • :created_override - override the value for the signature's 'created' parameter in the Authorization header

  • :expires_override - override the value for the signature's 'expires' parameter in the Authorization header