Documentation
¶
Index ¶
- Constants
- func GetHMACHeaders(r *http.Request) (appID, nonce, timestamp, signature string)
- func HMACMiddleware(secretsPerAppIDs map[string][]byte, nonceCache HMACNonceCache, ...) func(next http.Handler) http.Handler
- func HMACSign(secret, payload []byte) string
- func HMACVerify(secret, payload []byte, signature string) error
- func SetHMACHeaders(r *http.Request, appID, nonce, timestamp, signature string)
- type HMACNonceCache
Constants ¶
View Source
const ( HMACHeaderAppID = "X-Auth-App-ID" HMACHeaderSignature = "X-Auth-Signature" HMACHeaderNonce = "X-Auth-Nonce" HMACHeaderTimestamp = "X-Auth-Timestamp" )
Request headers required for HMAC authorization.
Variables ¶
This section is empty.
Functions ¶
func GetHMACHeaders ¶
GetHMACHeaders returns the HMAC auth headers from an HTTP request.
func HMACMiddleware ¶
func HMACMiddleware( secretsPerAppIDs map[string][]byte, nonceCache HMACNonceCache, nonceExpiration time.Duration, requestLogger func(r *http.Request) *zap.Logger, ) func(next http.Handler) http.Handler
HMACMiddleware validates the signature header which is a HEX-encoded SHA512 HMAC of nonce, timestamp and secret. Signature timestamp is considered valid for nonceExpiration duration and nonce values must be unique within this timeframe.
func HMACSign ¶
HMACSign creates a new hex-encoded SHA512 HMAC signature for the specified secret and payload.
func HMACVerify ¶
HMACVerify verifies the given hex-encoded SHA512 HMAC signature for the specified secret and payload.
func SetHMACHeaders ¶
SetHMACHeaders sets the specified HMAC auth headers on an HTTP request.
Types ¶
Click to show internal directories.
Click to hide internal directories.