* [Description](#description) * [Data Types](#types) * [Function Index](#index) * [Function Details](#functions) This module contains operations for manipulating and inspecting macaroons. Copyright (c) (C) 2015, Konrad Zemek All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. __Authors:__ Konrad Zemek. ## Data Types ## ### macaroon() ###

macaroon() = #macaroon{}
## Function Index ##
add_first_party_caveat/2 Returns a new macaroon with new first-party caveat.
add_third_party_caveat/4 Returns a new macaroon with new third-party caveat.
create/3 Creates a macaroon with set location (hint), key (secret) and id (public) attributes.
deserialize/1 Deserializes a macaroon from base64url-encoded binary.
identifier/1 Returns macaroon's identifier (public) attribute.
inspect/1 Returns a human-readable binary that describes the macaroon.
location/1 Returns macaroon's location (hint) attribute.
prepare_for_request/2 Returns a new discharge macaroon bounded to the parent macaroon.
serialize/1 Serializes the macaroon into base64url-encoded binary.
signature/1 Returns macaroon's signature.
suggested_secret_length/0 Returns the ideal length of secret key used for creating macaroons.
third_party_caveats/1 Returns a list of third-party caveats of the macaroon.
## Function Details ## ### add_first_party_caveat/2 ###

add_first_party_caveat(Macaroon::macaroon(), Caveat::iodata()) -> macaroon()

Returns a new macaroon with new first-party caveat. ### add_third_party_caveat/4 ###

add_third_party_caveat(Macaroon::macaroon(), Location::iodata(), Key::iodata(), Id::iodata()) -> macaroon()

Returns a new macaroon with new third-party caveat. The caveat is built from given location (hint), key (secret) and id (public) attributes. ### create/3 ###

create(Location::iodata(), Key::iodata(), Id::iodata()) -> macaroon()

Creates a macaroon with set location (hint), key (secret) and id (public) attributes. ### deserialize/1 ###

deserialize(Data::iodata()) -> {ok, macaroon()} | {error, macaroon_invalid}

Deserializes a macaroon from base64url-encoded binary. The serialized format must be compatible with libmacaroons reference implementation. ### identifier/1 ###

identifier(Macaroon::macaroon()) -> binary()

Returns macaroon's identifier (public) attribute. ### inspect/1 ###

inspect(Macaroon::macaroon()) -> binary()

Returns a human-readable binary that describes the macaroon. The function is only intended for debugging, and can for example be used with `io:format("~s", [inspect(M)])`. ### location/1 ###

location(Macaroon::macaroon()) -> binary()

Returns macaroon's location (hint) attribute. ### prepare_for_request/2 ###

prepare_for_request(Macaroon::macaroon(), Dispatch::macaroon()) -> macaroon()

Returns a new discharge macaroon bounded to the parent macaroon. ### serialize/1 ###

serialize(Macaroon::macaroon()) -> {ok, binary()} | {error, {too_long, term()}}

Serializes the macaroon into base64url-encoded binary. The serialized format is compatible with libmacaroons reference implementation. ### signature/1 ###

signature(Macaroon::macaroon()) -> binary()

Returns macaroon's signature. ### suggested_secret_length/0 ###

suggested_secret_length() -> non_neg_integer()

Returns the ideal length of secret key used for creating macaroons. ### third_party_caveats/1 ###

third_party_caveats(Macaroon::macaroon()) -> [{Location::binary(), Id::binary}]

Returns a list of third-party caveats of the macaroon. Each caveat is represented as a {location (hint), id (public)} tuple.