import "gopkg.in/macaroon.v1"
The macaroon package implements macaroons as described in the paper "Macaroons: Cookies with Contextual Caveats for Decentralized Authorization in the Cloud" (http://theory.stanford.edu/~ataly/Papers/macaroons.pdf)
See the macaroon bakery packages at http://godoc.org/gopkg.in/macaroon-bakery.v0 for higher level services and operations that use macaroons.
crypto.go macaroon.go marshal.go packet.go
type Macaroon struct {
// contains filtered or unexported fields
}Macaroon holds a macaroon. See Fig. 7 of http://theory.stanford.edu/~ataly/Papers/macaroons.pdf for a description of the data contained within. Macaroons are mutable objects - use Clone as appropriate to avoid unwanted mutation.
New returns a new macaroon with the given root key, identifier and location.
AddFirstPartyCaveat adds a caveat that will be verified by the target service.
AddThirdPartyCaveat adds a third-party caveat to the macaroon, using the given shared root key, caveat id and location hint. The caveat id should encode the root key in some way, either by encrypting it with a key known to the third party or by holding a reference to it stored in the third party's storage.
Bind prepares the macaroon for being used to discharge the macaroon with the given signature sig. This must be used before it is used in the discharges argument to Verify.
Caveats returns the macaroon's caveats. This method will probably change, and it's important not to change the returned caveat.
Clone returns a copy of the receiving macaroon.
Id returns the id of the macaroon. This can hold arbitrary information.
Location returns the macaroon's location hint. This is not verified as part of the macaroon.
MarshalBinary implements encoding.BinaryMarshaler.
MarshalJSON implements json.Marshaler.
Signature returns the macaroon's signature.
UnmarshalBinary implements encoding.BinaryUnmarshaler.
UnmarshalJSON implements json.Unmarshaler.
func (m *Macaroon) Verify(rootKey []byte, check func(caveat string) error, discharges []*Macaroon) error
Verify verifies that the receiving macaroon is valid. The root key must be the same that the macaroon was originally minted with. The check function is called to verify each first-party caveat - it should return an error if the condition is not met.
The discharge macaroons should be provided in discharges.
Verify returns nil if the verification succeeds.
Slice defines a collection of macaroons. By convention, the first macaroon in the slice is a primary macaroon and the rest are discharges for its third party caveats.
MarshalBinary implements encoding.BinaryMarshaler.
UnmarshalBinary implements encoding.BinaryUnmarshaler.
Package macaroon imports 11 packages (graph) and is imported by 522 packages. Updated 2017-08-17. Refresh now. Tools for package owners.