Documentation ¶
Index ¶
- Constants
- Variables
- func CORSMiddleware(next http.Handler) http.Handler
- func ComputeHmac(message string, secret string) string
- func DevKey(w http.ResponseWriter, r *http.Request)
- func GenHMAC() string
- func HMACMiddleware(next http.Handler) http.Handler
- func Logger(next http.Handler) http.Handler
- func MakeResidue(hmac string) string
- func SetupContextMiddleware(next http.Handler) http.Handler
- func ValidateHMAC(hmac string) bool
Constants ¶
const ( // RWords is a residual string used to mimic the actual HMAC RWords = "" /* 788-byte string literal not displayed */ )
Variables ¶
var ( // HMACAgeMinutes holds the validity (in minutes) of the hmac HMACAgeMinutes int // SecretKey holds the hmac secret SecretKey string )
Functions ¶
func CORSMiddleware ¶
CORSMiddleware will handle CORS handling
func ComputeHmac ¶
ComputeHmac will calculate and create new HMAC-SHA256 string hash based on the payload and the secret string
func DevKey ¶
func DevKey(w http.ResponseWriter, r *http.Request)
DevKey can be invoked from curl -X PUT -H "HocusPocus: AvadaCadavra" http://localhost:50051/devkey
func GenHMAC ¶
func GenHMAC() string
GenHMAC will generate a new HMAC string using the current time in RFC3339 format as payload .
func HMACMiddleware ¶
HMACMiddleware will handle the HMAC verification for each request of all restricted endpoint.
func SetupContextMiddleware ¶
SetupContextMiddleware will check if the current request already contains a context or not If it do not contain a context, a new context from background will be used and inserted into the request. The context is then injected with XRequestID key taken from the request header (or a new request id if theres no such header). This will be useful to chain the logs based on the request.
func ValidateHMAC ¶
ValidateHMAC will validate if a specific HMAC string is valid, it will open the time payload and make sure the payload is not expired and it equals to the hash
Types ¶
This section is empty.