auth

package
v0.0.0-...-2b080f0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultInvoiceLookupTimeout is the default maximum time we wait for
	// an invoice update to arrive.
	DefaultInvoiceLookupTimeout = 3 * time.Second
)
View Source
const Subsystem = "AUTH"

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type Authenticator

type Authenticator interface {
	// Accept returns whether or not the header successfully authenticates
	// the user to a given backend service.
	Accept(*http.Header, string) bool

	// FreshChallengeHeader returns a header containing a challenge for the
	// user to complete.
	FreshChallengeHeader(*http.Request, string, string, int64) (http.Header, error)
}

Authenticator is the generic interface for validating client headers and returning new challenge headers.

type InvoiceChecker

type InvoiceChecker interface {
	// VerifyInvoiceStatus checks that an invoice identified by a payment
	// hash has the desired status. To make sure we don't fail while the
	// invoice update is still on its way, we try several times until either
	// the desired status is set or the given timeout is reached.
	VerifyInvoiceStatus(lntypes.Hash, lnrpc.Invoice_InvoiceState,
		time.Duration) error
}

InvoiceChecker is an entity that is able to check the status of an invoice, particularly whether it's been paid or not.

type Level

type Level string
const (
	// LevelOff is the default level where no authentication is required.
	LevelOff Level = "off"
)

func (Level) FreebieCount

func (l Level) FreebieCount() freebie.Count

func (Level) IsFreebie

func (l Level) IsFreebie() bool

func (Level) IsOff

func (l Level) IsOff() bool

func (Level) IsOn

func (l Level) IsOn() bool

type LsatAuthenticator

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

LsatAuthenticator is an authenticator that uses the LSAT protocol to authenticate requests.

func NewLsatAuthenticator

func NewLsatAuthenticator(minter Minter,
	checker InvoiceChecker) *LsatAuthenticator

NewLsatAuthenticator creates a new authenticator that authenticates requests based on LSAT tokens.

func (*LsatAuthenticator) Accept

func (l *LsatAuthenticator) Accept(header *http.Header, serviceName string) bool

Accept returns whether or not the header successfully authenticates the user to a given backend service.

NOTE: This is part of the Authenticator interface.

func (*LsatAuthenticator) FreshChallengeHeader

func (l *LsatAuthenticator) FreshChallengeHeader(r *http.Request,
	serviceName string, serviceRecipientLud16 string, servicePrice int64) (http.Header, error)

FreshChallengeHeader returns a header containing a challenge for the user to complete.

NOTE: This is part of the Authenticator interface.

type Minter

type Minter interface {
	// MintLSAT mints a new LSAT for the target services.
	MintLSAT(context.Context, ...lsat.Service) (*macaroon.Macaroon, string, error)

	// VerifyLSAT attempts to verify an LSAT with the given parameters.
	VerifyLSAT(context.Context, *mint.VerificationParams) error
}

Minter is an entity that is able to mint and verify LSATs for a set of services.

type MockAuthenticator

type MockAuthenticator struct{}

MockAuthenticator is a mock implementation of the authenticator.

func NewMockAuthenticator

func NewMockAuthenticator() *MockAuthenticator

NewMockAuthenticator returns a new MockAuthenticator instance.

func (MockAuthenticator) Accept

func (a MockAuthenticator) Accept(header *http.Header, _ string) bool

Accept returns whether or not the header successfully authenticates the user to a given backend service.

func (MockAuthenticator) FreshChallengeHeader

func (a MockAuthenticator) FreshChallengeHeader(r *http.Request,
	_ string, _ string, _ int64) (http.Header, error)

FreshChallengeHeader returns a header containing a challenge for the user to complete.

Jump to

Keyboard shortcuts

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