tokens

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Debugger

type Debugger interface {
	Debug(...any)
}

type Tokens

type Tokens struct {
	// contains filtered or unexported fields
}

Tokens is a collection of tokens belonging to the user. This includes macaroon tokens (per-org) and OAuth tokens (per-user).

It is normal for this to include just macaroons, just oauth tokens, or a combination of the two. The GraphQL API is the only service that accepts macaroons and OAuth tokens in the same request. For other service, macaroons are preferred.

func Parse

func Parse(token string) *Tokens

Parse extracts individual tokens from a token string. The input token may include an authorization scheme (`Bearer` or `FlyV1`) and/or a set of comma-separated macaroon and user tokens.

func ParseFromFile added in v0.1.5

func ParseFromFile(token, fromFile string) *Tokens

ParseFromFile is like Parse but also records the file path that the tokens came from.

func (*Tokens) AddTokens added in v0.1.5

func (t *Tokens) AddTokens(toks ...string) *Tokens

AddTokens adds one or more tokens to t.

func (*Tokens) All

func (t *Tokens) All() string

func (*Tokens) Bubblegum

func (t *Tokens) Bubblegum() string

func (*Tokens) BubblegumHeader

func (t *Tokens) BubblegumHeader() string

func (*Tokens) Copy added in v0.1.5

func (t *Tokens) Copy() *Tokens

Copy returns a deep copy of t.

func (*Tokens) Docker

func (t *Tokens) Docker() string

func (*Tokens) Empty added in v0.1.5

func (t *Tokens) Empty() bool

Empty returns true if t has no tokens.

func (*Tokens) Equal added in v0.1.5

func (t *Tokens) Equal(other *Tokens) bool

Equal returns true if t and other are equal.

func (*Tokens) Flaps

func (t *Tokens) Flaps() string

func (*Tokens) FlapsHeader

func (t *Tokens) FlapsHeader() string

func (*Tokens) FromFile added in v0.1.5

func (t *Tokens) FromFile() string

FromFile returns the file path that was provided to ParseFromFile().

func (*Tokens) GetMacaroonTokens added in v0.1.5

func (t *Tokens) GetMacaroonTokens() []string

GetMacaroonTokens returns the macaroon tokens.

func (*Tokens) GetUserTokens added in v0.1.5

func (t *Tokens) GetUserTokens() []string

GetUserTokens returns the user tokens.

func (*Tokens) GraphQL

func (t *Tokens) GraphQL() string

func (*Tokens) GraphQLHeader

func (t *Tokens) GraphQLHeader() string

func (*Tokens) MacaroonsOnly added in v0.1.5

func (t *Tokens) MacaroonsOnly() *Tokens

MacaroonsOnly returns a copy of t with only macaroon tokens.

func (*Tokens) NATS

func (t *Tokens) NATS() string

func (*Tokens) Replace

func (t *Tokens) Replace(other *Tokens)

Replace replaces t with other.

func (*Tokens) ReplaceMacaroonTokens added in v0.1.5

func (t *Tokens) ReplaceMacaroonTokens(macs []string)

ReplaceMacaroonTokens replaces the macaroon tokens with macs.

func (*Tokens) Update

func (t *Tokens) Update(ctx context.Context, opts ...UpdateOption) (bool, error)

Update prunes any invalid/expired macaroons and fetches needed third party discharges

func (*Tokens) UserTokenOnly added in v0.1.5

func (t *Tokens) UserTokenOnly() *Tokens

UserTokenOnly returns a copy of t with only user tokens.

type UpdateOption

type UpdateOption func(*updateOptions)

func WithDebugger

func WithDebugger(d Debugger) UpdateOption

func WithUserURLCallback

func WithUserURLCallback(cb func(ctx context.Context, url string) error) UpdateOption

Jump to

Keyboard shortcuts

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