Documentation
¶
Index ¶
- Constants
- func CryptoHashToDigestName(id crypto.Hash) (result string, err error)
- func DigestNameToCryptoHash(name string) (result crypto.Hash, err error)
- type AuthenticationResult
- type HmacAuth
- func (auth *HmacAuth) AuthenticateRequest(request *http.Request) (result AuthenticationResult, headerSignature, computedSignature string)
- func (auth *HmacAuth) RequestSignature(req *http.Request) string
- func (auth *HmacAuth) SignRequest(req *http.Request)
- func (auth *HmacAuth) SignatureFromHeader(req *http.Request) string
- func (auth *HmacAuth) StringToSign(req *http.Request) string
Constants ¶
const (
// SigSeparator is the separator character in the signature that separates the algorithm from the signature.
SigSeparator = "="
)
Variables ¶
This section is empty.
Functions ¶
func CryptoHashToDigestName ¶
CryptoHashToDigestName returns the algorithm name corresponding to the crypto.Hash ID, or an error if the algorithm is not supported.
Types ¶
type AuthenticationResult ¶
type AuthenticationResult int
AuthenticationResult is a code used to identify the outcome of HmacAuth.AuthenticateRequest().
const ( // ResultNoSignature - the incoming result did not have a signature // header. ResultNoSignature AuthenticationResult = iota // ResultInvalidFormat - the signature header was not parseable. ResultInvalidFormat // ResultUnsupportedAlgorithm - the signature header specified an // unsupported algorithm. ResultUnsupportedAlgorithm // ResultMatch - the signature from the request header matched the // locally-computed signature. ResultMatch // ResultMismatch - the signature from the request header did not match // the locally-computed signature. ResultMismatch )
func (AuthenticationResult) String ¶
func (result AuthenticationResult) String() string
type HmacAuth ¶
type HmacAuth struct {
// contains filtered or unexported fields
}
HmacAuth signs outbound requests and authenticates inbound requests.
func NewHmacAuth ¶
func NewHmacAuth(hash crypto.Hash, key []byte, header string, headers []string, bodyOnly bool) *HmacAuth
NewHmacAuth returns an HmacAuth object that can be used to sign or authenticate HTTP requests based on the supplied parameters.
func (*HmacAuth) AuthenticateRequest ¶
func (auth *HmacAuth) AuthenticateRequest(request *http.Request) ( result AuthenticationResult, headerSignature, computedSignature string)
AuthenticateRequest authenticates the request, returning the result code, the signature from the header, and the locally-computed signature.
func (*HmacAuth) RequestSignature ¶
RequestSignature Generates a signature for the request.
func (*HmacAuth) SignRequest ¶
func (*HmacAuth) SignatureFromHeader ¶
SignatureFromHeader retrieves the signature included in the request header.