View Source AppIdentity.TeslaMiddleware (AppIdentity for Elixir v1.2.0)
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. SeeAppIdentity.disallowed/0
.header
: (required) The 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 ifon_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 middlewareenv
value;app
: The identity app value provided to the middleware; andheader
: 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
.
Link to this section Summary
Link to this section Types
@type on_failure() :: :fail | :pass | :skip
@type on_failure_fn() :: (Tesla.Env.t(), AppIdentity.App.t(), header :: String.t() -> on_failure() | Tesla.Env.t()) | {module(), function :: atom()}
@type option() :: AppIdentity.disallowed() | {:app, AppIdentity.App.input() | AppIdentity.App.loader() | AppIdentity.App.t()} | {:header, String.t()} | {:on_failure, on_failure() | on_failure_fn()}