Documentation
¶
Overview ¶
Package provider decides whether an inbound request really came from the provider it claims to be.
Nothing here knows a vendor's name. A vendor is a set of parameters, and a preset is a name for such a set. Adding support for one is registration or configuration, never a new branch.
Index ¶
Constants ¶
const ( Simple = "simple" Advanced = "advanced" )
How the signature header is laid out.
const ( SHA1 = "sha1" SHA256 = "sha256" SHA512 = "sha512" )
const ( Hex = "hex" Base64 = "base64" )
const ( BasicAuth = "basic-auth" )
Proof that carries no signature: the caller only shows it knows the secret. It says nothing about the body, and is what a provider that does not sign leaves you with.
const HMAC = "hmac"
Variables ¶
var ( ErrNoProof = errors.New("the request carried no proof of origin") ErrMalformed = errors.New("the proof is malformed") ErrMismatch = errors.New("the proof does not match") ErrStale = errors.New("the proof is outside the tolerance window") ErrNoSecret = errors.New("no secret is configured") ErrUnknownKind = errors.New("unknown verifier") ErrUnknownOption = errors.New("unknown option") )
Functions ¶
func Algorithms ¶
func Algorithms() []string
func PresetNames ¶
func PresetNames() []string
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache holds a built verifier per tenant and provider, so checking a request costs no query and no construction. A provider that is absent gets the verifier that checks nothing, which is why a cold or failed load can never keep a request from being recorded.
type Preset ¶
A preset is a name for a set of parameters. It adds no behaviour: everything it fills in could be typed by hand, and nothing reads the name at runtime.
func PresetByName ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps a kind of proof to the code that builds it. Supporting a new kind is a call to Register, not an edit to a conditional.
func Default ¶
func Default() *Registry
Default is the registry this project ships with: the kinds of proof a provider can offer, and nothing about who offers them.
func NewRegistry ¶
func NewRegistry() *Registry
type Request ¶
Request is what a verifier is allowed to look at. The body is the exact bytes received, because that is what was signed.
type Settings ¶
type Settings struct {
Verifier string
Secret string
Header string
Scheme string
Algorithm string
Encoding string
TimestampKey string
SignatureKey string
Tolerance time.Duration
}
Settings are the parameters as an operator stores them.
type Source ¶
type Source interface {
AllVerification(ctx context.Context) (map[uuid.UUID]map[string]Settings, error)
ProviderChanges(ctx context.Context) <-chan struct{}
}
Source is where the settings come from. Declared here, by the side that consumes it, so this package depends on no storage.
type Unverified ¶
type Unverified struct{}
Unverified stands for a provider nobody configured. It is a verifier so that the inbound port has one path, not two.