macaroon

package
v0.0.0-...-4ce4a32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: MPL-2.0 Imports: 11 Imported by: 1

README

Macaroon CLI Generation

This tool provides a mechanism for creation of macaroon tokens from the command line provided there is a yaml file defining all of the tokens one wishes to generate, as well as the HMAC secret key.

cd bat-go/ # go to root of bat-go repository
go build ./... # build the bat-go exec
./bat-go macaroon create --config cmd/macaroon/brave-talk/brave_talk_free_dev.yaml --secret secret

The above command will read "example.yaml" parse it into a token config and then create macaroons based on the tokens specified in the yaml file. Below is an example yaml file:

---
tokens:
  - 
      id: "brave user-wallet-vote sku token v2"
      version: 2
      location: "brave.com"
      first_party_caveats:
          - id: "ef0db4e2-c247-4b9b-99ab-5fc72213ac3a"
          - sku: "user-wallet-vote"
  - 
      id: "brave anon-card-vote sku token v2"
      version: 2
      location: "brave.com"
      first_party_caveats:
          - id: "5cbe9620-ca98-4d09-8c18-1b8582d78e60"
          - sku: "anon-card-vote"

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MacaroonCmd is a subcommand for macaroons
	MacaroonCmd = &cobra.Command{
		Use:   "macaroon",
		Short: "macaroon subcommand",
	}
	// MacaroonCreateCmd generates a macaroon
	MacaroonCreateCmd = &cobra.Command{
		Use:   "create",
		Short: "create a macaroon",
		Run:   cmd.Perform("macaroon creation", RunMacaroonCreate),
	}
)

Functions

func Generate

func Generate(ctx context.Context, config, secret string) error

Generate generates macaroons

func RunMacaroonCreate

func RunMacaroonCreate(command *cobra.Command, args []string) error

RunMacaroonCreate runs the generate command

Types

type Caveats

type Caveats map[string]string

Caveats - configuration representation of key pair caveats

type Token

type Token struct {
	ID                string    `yaml:"id"`
	Version           int       `yaml:"version"`
	Location          string    `yaml:"location"`
	FirstPartyCaveats []Caveats `yaml:"first_party_caveats"`
}

Token - configuration representation of token metadata attributes

func (Token) Generate

func (t Token) Generate(secret string) (string, error)

Generate - Generate a Macaroon from the Token configuration

type TokenConfig

type TokenConfig struct {
	Tokens []Token `yaml:"tokens"`
}

TokenConfig - structure of the token configuration file

func (*TokenConfig) Parse

func (tc *TokenConfig) Parse(path string) (err error)

Parse - Parse the token configuration file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL