verifier

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SignatureSplitPostProcessor = func(sep string, n int) func(r *http.Request, signature string) string {
		return func(r *http.Request, signature string) string {
			parts := strings.SplitN(signature, sep, n)
			if len(parts) == n {
				return parts[n-1]
			}
			return signature
		}
	}
)

Functions

This section is empty.

Types

type HmacConfig

type HmacConfig struct {
	Hash                   string
	Encoding               string
	SignatureHeader        string
	TimestampHeader        string
	SignaturePostProcessor SignaturePostProcessor
	MessagePostProcessor   MessagePostProcessor
}

type HmacOption

type HmacOption func(*HmacConfig)

func WithMessagePostProcessor

func WithMessagePostProcessor(fn MessagePostProcessor) HmacOption

func WithSignaturePostProcessor

func WithSignaturePostProcessor(fn SignaturePostProcessor) HmacOption

func WithTimestampHeader

func WithTimestampHeader(timestampHeader string) HmacOption

type HmacVerifier

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

func NewHmacVerifier

func NewHmacVerifier(hash, encoding, signatureHeader string, options ...HmacOption) *HmacVerifier

func (*HmacVerifier) Verify

func (v *HmacVerifier) Verify(ctx context.Context, req *Request, config map[string]interface{}) (*Result, error)

type HmacVerifyConfig

type HmacVerifyConfig struct {
	Secret          string `json:"secret"`
	ToleranceWindow int64  `json:"tolerance_window"`
}

type MessagePostProcessor

type MessagePostProcessor func(r *http.Request, message string) string

type Request

type Request struct {
	R *http.Request
}

Request verify request

type Response

type Response struct {
	StatusCode int
	Headers    map[string]string
	Body       []byte
}

Response verify http response

type Result

type Result struct {
	Verified bool
	Response *Response
}

Result verify result

type SignaturePostProcessor

type SignaturePostProcessor func(r *http.Request, signature string) string

type StandardWebhooksVerifier

type StandardWebhooksVerifier struct {
}

StandardWebhooksVerifier is standard-webhooks implementation

func NewStandardWebhooksVerifier

func NewStandardWebhooksVerifier() *StandardWebhooksVerifier

func (*StandardWebhooksVerifier) Verify

func (v *StandardWebhooksVerifier) Verify(ctx context.Context, req *Request, config map[string]interface{}) (*Result, error)

type StandardWebhooksVerifyConfig

type StandardWebhooksVerifyConfig struct {
	Secret          string `json:"secret"`
	ToleranceWindow int64  `json:"tolerance_window"`
}

type Verifier

type Verifier interface {
	Verify(context.Context, *Request, map[string]interface{}) (*Result, error)
}

func LoadVerifier

func LoadVerifier(provider string) (Verifier, bool)

type VerifyFunc

type VerifyFunc func(context.Context, *Request, map[string]interface{}) (*Result, error)

func (VerifyFunc) Verify

func (f VerifyFunc) Verify(ctx context.Context, req *Request, config map[string]interface{}) (*Result, error)

Jump to

Keyboard shortcuts

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