casedhttp

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 13 Imported by: 0

README

casedhttp

casedhttp is a package used to add auditing capabilities to the net/http package.

By using casedhttp's provided casedhttp.ContextMiddleware around your http.HandlerFunc each audit event published using cased.PublishWithContext will include the following properties:

Key Example Sensitive Value
location 1.1.1.1 ip-address
request_url /login -
request_http_method POST -
request_user_agent Mozilla/5.0 -
request_id 1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed -

Usage

See example for an example implementation.

Documentation

Index

Constants

View Source
const (
	WebhookTimestampHeader = "X-Cased-Timestamp"
	WebhookSignatureHeader = "X-Cased-Signature"
)

Variables

View Source
var (
	WebhookSecret                     = os.Getenv("CASED_WEBHOOK_SECRET")
	WebhookTimestampExpiredError      = errors.New("webhook timestamp expired")
	WebhookSignatureVerificationError = errors.New("webhook computed signature does not match signature sent with webhook")
)

Functions

func ContextMiddleware

func ContextMiddleware(next http.Handler) http.Handler

ContextMiddleware ...

func VerifyWebhookSignature added in v1.0.2

func VerifyWebhookSignature(req *http.Request, params *VerifyWebhookSignatureParams) error

func VerifyWebhookSignatureMiddleware added in v1.0.2

func VerifyWebhookSignatureMiddleware(next http.Handler, params *VerifyWebhookSignatureParams) http.Handler

Types

type VerifyWebhookSignatureParams added in v1.0.2

type VerifyWebhookSignatureParams struct {
	// Secret used to compute the HMAC signature. Optional if secret is provided
	// by the CASED_WEBHOOK_SECRET environment variable.
	Secret *string

	// TimestampExpires if provided will reject webhook requests that are
	// delivered after specified duration. Useful to prevent replay attacks. Each
	// webhook attempt delivered from Cased will provide a new timestamp.
	TimestampExpires time.Duration
}

Jump to

Keyboard shortcuts

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