View Source AppIdentity.TeslaMiddleware (AppIdentity for Elixir v1.3.1)

A Tesla middleware that generates an app identity proof header for a request.

The options provided has the following parameters:

  • app: (required) A value that can be passed to AppIdentity.App.new/1.

  • disallowed: A list of algorithm versions that are not allowed when processing received identity proofs. See AppIdentity.disallowed/0.

  • header: (required) The valid HTTP header to use for sending the app identity proof.

  • on_failure: (optional) The action to take when an app identity proof cannot be generated for any reason except configuration errors. May be one of the following values:

    • :fail: Fails the request with an error tuple. This is the default if on_failure is not specified.

    • :pass: Sets the header to the empty value returned. The request will probably fail on the receiving server side.

    • :skip: Does not add the header, as if the request were not made using an application.

on_failure may also be provided an arity 3 function or {module, function} tuple that expects three parameters:

  • env: The Tesla middleware env value;
  • app: The identity app value provided to the middleware; and
  • header: The header name provided to the middleware.

The function may return either the env, :fail, :skip, or :pass. Any other value will be treated as :fail.

Summary

Types

@type on_failure() :: :fail | :pass | :skip
@type on_failure_callback() ::
  (Tesla.Env.t(), AppIdentity.App.t(), header :: binary() ->
     on_failure() | Tesla.Env.t())
  | {module(), function :: atom()}
@type option() ::
  AppIdentity.disallowed()
  | {:app,
     AppIdentity.App.input() | AppIdentity.App.loader() | AppIdentity.App.t()}
  | {:header, binary()}
  | {:on_failure, on_failure() | on_failure_callback()}