Macaroon (macaroon v0.1.0)

This is the primary public interface for Elixir Macaroons

Link to this section Summary

Functions

Add a first-party caveat to a Macaroon provided a caveat_predicate

Add a third-party caveat to a Macaroon provided a location, caveat_id, and secret caveat_key

Create an empty Macaroon with a provided location, public_id and secret

Deserializes a JSON or Base64 serialized Macaroon string

This prepares a Macaroon for delegation to another third-party authorization service. Returns a "protected" (or bound) discharge Macaroon.

Serializes a Macaroon into a more transmittable format

Link to this section Functions

Link to this function

add_first_party_caveat(macaroon, caveat_predicate)

Specs

add_first_party_caveat(Macaroon.Types.Macaroon.t(), binary()) ::
  Macaroon.Types.Macaroon.t()

Add a first-party caveat to a Macaroon provided a caveat_predicate

Link to this function

add_third_party_caveat(macaroon, location, caveat_id, caveat_key, nonce \\ nil)

Specs

add_third_party_caveat(
  Macaroon.Types.Macaroon.t(),
  binary(),
  binary(),
  binary(),
  false | nil | binary()
) :: Macaroon.Types.Macaroon.t()

Add a third-party caveat to a Macaroon provided a location, caveat_id, and secret caveat_key

Link to this function

create_macaroon(location, public_identifier, secret)

Specs

create_macaroon(binary(), binary(), binary()) :: Macaroon.Types.Macaroon.t()

Create an empty Macaroon with a provided location, public_id and secret

Link to this function

deserialize(macaroon_json, atom)

Specs

deserialize(binary(), :binary | :json) :: Macaroon.Types.Macaroon.t()

Deserializes a JSON or Base64 serialized Macaroon string

2nd argument for "type" can be :binary or :json

Returns a Macaroon.Types.Macaroon struct

Link to this function

prepare_for_request(discharge_macaroon, macaroon)

Specs

This prepares a Macaroon for delegation to another third-party authorization service. Returns a "protected" (or bound) discharge Macaroon.

discharge_macaroon - The Macaroon that will be sent to the third-party service.

macaroon - The Macaroon that the discharge_macaroon will be bound to. (The "root" Macaroon)

Link to this function

serialize(macaroon, atom)

Specs

serialize(Macaroon.Types.Macaroon.t(), :binary | :json) ::
  nil
  | {:error,
     %{
       :__exception__ => any(),
       :__struct__ => Jason.EncodeError | Protocol.UndefinedError,
       optional(atom()) => any()
     }}
  | {:ok, binary()}

Serializes a Macaroon into a more transmittable format

2nd argument for "type" can be :binary or :json