Authoritex.HTTP.Auth (Authoritex v3.1.0)

Copy Markdown View Source

Module for handling HTTP authentication for Authoritex authorities.

Summary

Functions

Returns a Req-compatible auth option based on the provided configuration.

Functions

auth(method)

Returns a Req-compatible auth option based on the provided configuration.

Examples

# Retrieve AWS credentials from instance metadata or environment variables
iex> Authoritex.HTTP.Auth.auth(:aws)
[aws_sigv4: [access_key_id: "key", secret_access_key: "secret", token: "token", service: "es", region: "us-east-1"]]

# Use explicitly provided AWS credentials
iex> Authoritex.HTTP.Auth.auth({:aws, [access_key_id: "key", secret_access_key: "secret"]})
[aws_sigv4: [access_key_id: "key", secret_access_key: "secret", service: "es", region: "us-east-1"]]

# Use passthrough req auth methods (see https://hexdocs.pm/req/Req.Steps.html#auth/1 for supported formats)
iex> Authoritex.HTTP.Auth.auth({:basic, "username", "password"})
[auth: {:basic, "username", "password"}]

iex> Authoritex.HTTP.Auth.auth({:bearer, "token"})
[auth: {:bearer, "token"}]

iex> Authoritex.HTTP.Auth.auth({mod, fun, args})
[auth: {mod, fun, args}]