Documentation
¶
Index ¶
Constants ¶
const ( // DefaultInvoiceLookupTimeout is the default maximum time we wait for // an invoice update to arrive. DefaultInvoiceLookupTimeout = 3 * time.Second )
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.
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(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 L402Authenticator ¶
type L402Authenticator struct {
// contains filtered or unexported fields
}
L402Authenticator is an authenticator that uses the L402 protocol to authenticate requests.
func NewL402Authenticator ¶
func NewL402Authenticator(minter Minter, checker InvoiceChecker) *L402Authenticator
NewL402Authenticator creates a new authenticator that authenticates requests based on L402 tokens.
func (*L402Authenticator) Accept ¶
func (l *L402Authenticator) 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 (*L402Authenticator) FreshChallengeHeader ¶
func (l *L402Authenticator) FreshChallengeHeader(serviceName 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 Level ¶
type Level string
const ( // LevelOff is the default level where no authentication is required. LevelOff Level = "off" )
func (Level) FreebieCount ¶
type Minter ¶
type Minter interface {
// MintL402 mints a new L402 for the target services.
MintL402(context.Context, ...l402.Service) (*macaroon.Macaroon, string, error)
// VerifyL402 attempts to verify an L402 with the given parameters.
VerifyL402(context.Context, *mint.VerificationParams) error
}
Minter is an entity that is able to mint and verify L402s 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 ¶
FreshChallengeHeader returns a header containing a challenge for the user to complete.