signing

package
v0.0.0-...-5fb48e9 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package signing provides signing functionality for requests to/from Slack.

Index

Constants

View Source
const (
	// SlackTimestampHeader is the HTTP header that Slack uses for specifying
	// the timestamp used in generating the signature.
	SlackTimestampHeader = "X-Slack-Request-Timestamp"

	// SlackSignatureHeader is the HTTP header that Slack uses for specifying
	// the signature that was generated.
	SlackSignatureHeader = "X-Slack-Signature"
)

Variables

This section is empty.

Functions

func Sign

func Sign(key string, r *http.Request) error

Sign takes the signature key, and a request, and then signs the request using that key. Afterwards the request should be trusted by any application implementing this signature verification method.

func Validate

func Validate(key string, r Request) error

Validate takes the signature key, and the pieces of a request that allow us to validate its signature. If this returned an error, the validation failed. Returned errors are meant to be logged, not to be sent back to the entity making the request.

Types

type Request

type Request struct {
	// Timestamp is the X-Slack-Request-Timestamp HTTP request header
	Timestamp string

	// Signature is the X-Slack-Signature HTTP request header, which is the provided
	// HMAC signature
	Signature string

	// Body is the request body
	Body []byte
}

Request represents the pieces of a request needed to do a signature validation. We take this instead of an *http.Request so that we don't need to be responsible for rewinding its response body.

Jump to

Keyboard shortcuts

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