Macaroon (macaroon v0.3.1)
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 predicate
Add a third-party caveat to a Macaroon provided a location
, predicate
, and random 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
add_first_party_caveat(macaroon, 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 predicate
add_third_party_caveat(macaroon, location, predicate, 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
, predicate
, and random secret caveat_key
location
is a hint to where the client must go to prove this caveat
predicate
is a string that contains caveat_key
and the predicate we want to have this caveat assert
you should encrypt this in such a way that only the other party can decrypt it (pub/priv keys)
OR
retreieve an ID from the other service first and use that as the ID.
caveat_key
is the freshly generated secret key that will be encrypted using the current signature of the Macaroon
nonce
- you SHOULD NOT override this unless you know what you're doing (it defaults to secure random bytes)
it is used when encrypting the caveat_key
and should never be static unless you are testing something that requires
the signature to be static.
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
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
prepare_for_request(discharge_macaroon, macaroon)
Specs
prepare_for_request(Macaroon.Types.Macaroon.t(), Macaroon.Types.Macaroon.t()) :: Macaroon.Types.Macaroon.t()
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 back to the originating service
macaroon
- The Macaroon that the discharge_macaroon
will be bound to. (The "root" Macaroon)
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