sns

package module
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 13 Imported by: 0

README

sns

The sns package provides tooling to verify the authenticity of an Amazon SNS (Simple Notification Service) Payload. The validation process adheres to the guidelines outlined in the AWS Documentation.

Key Features
  • Ensures the SigningCertURL originates from a valid Amazon SNS domain.
  • Supports both the standard AWS regions (https://sns.<your-region>.amazonaws.com) and the AWS China regions (https://sns.<your-region>.amazonaws.com.cn).
Important Notes

1. TopicArn Validation:
This library does NOT perform validation on the TopicArn. Users of this library are responsible for handling this validation on their own.

2. SigningCertURL Whitelisting:
For added security, it is highly recommended to whitelist the SigningCertURL host against the specific AWS regions you're actively using (e.g., https://sns.us-west-1.amazonaws.com). This ensures that the certificate URL matches the intended region.

Documentation

Overview

Package sns provides AWS SNS related functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct{}

Client provides methods for interacting with AWS SNS.

func New

func New() *Client

New returns a Client ready to use

func (*Client) VerifyAuthenticity

func (c *Client) VerifyAuthenticity(ctx context.Context, reqBody io.Reader) (*Payload, error)

VerifyAuthenticity verifies that the body of the request is authentic (i.e., that it was sent by AWS SNS) and returns the payload.

type Payload

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

Payload represents the payload of an SNS message.

Jump to

Keyboard shortcuts

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