Documentation ¶
Overview ¶
Package signer provides an implementation of the HSDP API signing algorithm. It can sign standard Go http.Request
Index ¶
- Constants
- Variables
- func GetSharedKey(request *http.Request) (string, error)
- func Prefix(prefix string) func(*Signer) error
- func SignBody() func(*Signer) error
- func SignHeaders(headers ...string) func(*Signer) error
- func SignMethod() func(*Signer) error
- func SignParam() func(*Signer) error
- func WithNowFunc(nowFunc NowFunc) func(*Signer) error
- type NowFunc
- type Signer
Constants ¶
View Source
const ( LogTimeFormat = "2006-01-02T15:04:05.000Z07:00" TimeFormat = time.RFC3339 HeaderAuthorization = "hsdp-api-signature" HeaderSignedDate = "SignedDate" DefaultPrefix64 = "REhQV1M=" AlgorithmName = "HmacSHA256" )
Constants
Variables ¶
View Source
var ( ErrSignatureExpired = errors.New("signature expired") ErrInvalidSignature = errors.New("invalid signature") ErrInvalidCredential = errors.New("invalid credential") ErrNotSupportedYet = errors.New("missing implementation, please contact the author(s)") ErrInvalidNowFunc = errors.New("invalid now function") )
Errors
Functions ¶
func GetSharedKey ¶ added in v1.2.0
GetSharedKey extracts the shared key from request
func SignHeaders ¶ added in v1.3.0
SignHeaders includes the headers if present
func SignMethod ¶ added in v1.2.0
SignMethod includes body in the signature
func WithNowFunc ¶ added in v1.2.0
WithNowFunc uses the nowFunc as the source of time
Types ¶
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer holds the configuration of a signer instance
func NewWithPrefixAndNowFunc ¶
func NewWithPrefixAndNowFunc(sharedKey, sharedSecret, prefix string, nowFunc NowFunc) (*Signer, error)
NewWithPrefixAndNowFunc create na instance of Signer, taking prefix and nowFunc as additional parameters
func (*Signer) SignRequest ¶
SignRequest signs a http.Request by adding an Authorization and SignedDate header
Click to show internal directories.
Click to hide internal directories.