Documentation
¶
Overview ¶
Package provider defines the interface an inbound event provider implements: creation-time defaults, envelope decoding, request verification, protocol handshakes, and rejection behavior. Base supplies the complete default behavior so plain providers are declarative data and protocol-heavy providers override only what differs.
Index ¶
- Variables
- type AuthConfig
- type AuthType
- type Base
- func (b Base) Decoder(envelopeType EnvelopeType) (envelope.Decoder, error)
- func (b Base) Defaults() Defaults
- func (b Base) Handshake(*envelope.Event) (*Handshake, error)
- func (b Base) Name() string
- func (b Base) RejectStatus(error) int
- func (b Base) Verifier(auth AuthType, cfg AuthConfig) signature.Verifier
- type CallerField
- type Defaults
- type EnvelopeType
- type Handshake
- type Provider
Constants ¶
This section is empty.
Variables ¶
var ErrConflictingAuthConfig = errors.New("conflicting auth_config")
ErrConflictingAuthConfig is returned by ApplyDefaults when the caller supplies auth config that contradicts the provider defaults.
var ErrUnsupportedEnvelope = errors.New("trigger envelope is not implemented")
ErrUnsupportedEnvelope is returned by Decoder for envelope types the provider does not implement.
Functions ¶
This section is empty.
Types ¶
type AuthConfig ¶
type AuthConfig struct {
Header string `json:"header,omitempty"`
Prefix string `json:"prefix,omitempty"`
Encoding string `json:"encoding,omitempty"`
Algorithm string `json:"algorithm,omitempty"`
Username string `json:"username,omitempty"`
Issuer string `json:"issuer,omitempty"`
Audience []string `json:"audience,omitempty"`
TopicARN string `json:"topic_arn,omitempty"`
ExpectedEmail string `json:"expected_email,omitempty"`
ExpectedSubject string `json:"expected_subject,omitempty"`
}
AuthConfig configures how inbound requests authenticate.
func ApplyDefaults ¶
func ApplyDefaults(defaults Defaults, provided AuthConfig) (AuthConfig, error)
ApplyDefaults resolves a caller-supplied auth config against provider defaults: caller fields are adopted, unset basic fields are defaulted, and any remaining difference is a conflict.
type Base ¶
Base is the default Provider implementation: config-driven decoding and verification, no handshake, and accept-and-record rejection.
func (Base) RejectStatus ¶
type CallerField ¶
type CallerField string
CallerField names an AuthConfig field the caller supplies at creation time instead of the provider defaults.
const ( CallerFieldAudience CallerField = "audience" CallerFieldExpectedEmail CallerField = "expected_email" CallerFieldExpectedSubject CallerField = "expected_subject" CallerFieldTopicARN CallerField = "topic_arn" )
type Defaults ¶
type Defaults struct {
Auth AuthType
Envelope EnvelopeType
AuthConfig AuthConfig
TypeFrom envelope.FieldSelector
IDFrom envelope.FieldSelector
CallerFields []CallerField
// NativeProtocol marks providers that speak their own webhook protocol:
// the envelope decoder is fixed and field selectors do not apply.
NativeProtocol bool
// CallerSecret marks providers whose signing secret is issued by the
// external provider and supplied by the caller at creation time. Such
// secrets are write-only: they cannot be revealed, rotated, or revoked
// independently of the trigger.
CallerSecret bool
}
Defaults is the declarative creation-time configuration a provider preset applies to a trigger.
type EnvelopeType ¶
type EnvelopeType string
const ( EnvelopeNone EnvelopeType = "none" EnvelopePubSubPush EnvelopeType = "pubsub_push" EnvelopeCloudEvents EnvelopeType = "cloudevents" EnvelopeSNS EnvelopeType = "sns" )
type Handshake ¶
Handshake is a provider protocol response that ends request processing without persisting an event, such as Slack URL verification or Azure Event Grid subscription validation.
type Provider ¶
type Provider interface {
Name() string
Defaults() Defaults
// Decoder returns the envelope decoder for the trigger's configured
// envelope type. Native-protocol providers ignore the envelope type.
Decoder(envelopeType EnvelopeType) (envelope.Decoder, error)
// Verifier returns the shared-secret verifier for the trigger's auth
// mechanism, or nil for mechanisms that do not verify against managed
// secrets (none, bearer_jwt, sns_signature).
Verifier(auth AuthType, cfg AuthConfig) signature.Verifier
// Handshake inspects a decoded event and returns a non-nil response when
// the request is a protocol handshake rather than an event delivery.
Handshake(event *envelope.Event) (*Handshake, error)
// RejectStatus returns the HTTP status for an envelope decode failure.
// http.StatusAccepted means record the rejection and acknowledge the
// delivery; other statuses surface the error to the sender.
RejectStatus(err error) int
}
Provider implements one inbound event source. All methods are complete on Base; providers embed Base and override only protocol-specific behavior.