sns

package
v0.19.1237 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package sns parses and verifies AWS SNS HTTP(S) deliveries: message envelope validation, signing certificate retrieval, RSA signature verification, and subscription URL validation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateSubscribeURL

func ValidateSubscribeURL(rawURL, topicARN, token string) error

ValidateSubscribeURL rejects a SubscribeURL unless it is a trusted SNS endpoint whose ConfirmSubscription query matches the signed message.

Types

type Decoder

type Decoder struct{}

Decoder decodes an SNS Notification into a normalized event. Confirmations yield a nil event: they are valid requests with nothing to persist.

func (Decoder) Decode

func (Decoder) Decode(_ http.Header, body []byte) (*envelope.Event, error)

type Message

type Message struct {
	Type             string `json:"Type"`
	MessageID        string `json:"MessageId"`
	TopicARN         string `json:"TopicArn"`
	Subject          string `json:"Subject,omitempty"`
	Message          string `json:"Message"`
	Timestamp        string `json:"Timestamp"`
	SignatureVersion string `json:"SignatureVersion"`
	Signature        string `json:"Signature"`
	SigningCertURL   string `json:"SigningCertURL"`
	Token            string `json:"Token,omitempty"`
	SubscribeURL     string `json:"SubscribeURL,omitempty"`
}

Message is an SNS delivery: a Notification, SubscriptionConfirmation, or UnsubscribeConfirmation.

func ParseMessage

func ParseMessage(body []byte) (*Message, error)

ParseMessage decodes and validates an SNS message body, including its SigningCertURL and, for confirmations, its SubscribeURL.

type Verifier

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

Verifier verifies SNS message signatures, fetching and caching the AWS signing certificates.

func NewVerifier

func NewVerifier(client *http.Client) *Verifier

NewVerifier returns a Verifier that fetches signing certificates with client, or http.DefaultClient when client is nil.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, msg *Message) error

Verify checks msg's RSA signature against the AWS signing certificate for the topic's region.

Jump to

Keyboard shortcuts

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