signer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2018 License: MIT Imports: 7 Imported by: 0

README

Go HSDP Signer

This package implements the HSDP API signing algorithm. You can sign a http.Request instances

Usage


import (
  "github.com/philips-software/go-hsdp-signer"
  "net/http"
)

func signFilter(req *http.Request, sharedKey, secretKey string) (*http.Request, error) {
    s, err := signer.New(sharedKey, secretKey)
    if err != nil {
        return nil, err
    }
    s.SignRequest(req)
    return req, nil
}

License

Licensed is MIT

Documentation

Overview

Package signer provides an implementation of the HSDP API signing algorithm. It can sign standard Go http.Request

Index

Constants

This section is empty.

Variables

View Source
var (
	LOG_TIME_FORMAT      = "2006-01-02T15:04:05.000Z07:00"
	TIME_FORMAT          = time.RFC3339
	AUTHORIZATION_HEADER = "hsdp-api-signature"
	SIGNED_DATE_HEADER   = "SignedDate"
	DEFAULT_PREFIX_64    = "REhQV1M="
	ALGORITHM_NAME       = "HmacSHA256"
)

Functions

This section is empty.

Types

type NowFunc

type NowFunc func() time.Time

type Signer

type Signer struct {
	// contains filtered or unexported fields
}

Signer holds the configuration of a signer instance

func New

func New(sharedKey, sharedSecret string) (*Signer, error)

New creates an instance of Signer

func NewWithPrefixAndNowFunc

func NewWithPrefixAndNowFunc(sharedKey, sharedSecret, prefix string, nowFunc NowFunc) (*Signer, error)

NewWithPrefixAndNowFunc create na instace of Signer, taking prefix and nowFunc as additional parameters

func (*Signer) SignRequest

func (s *Signer) SignRequest(request *http.Request) error

SignsRequest signs a http.Request by adding an Authorization and SignedDate header

func (*Signer) ValidateRequest

func (s *Signer) ValidateRequest(request *http.Request) (bool, error)

ValidateRequests validates a previously signed request

Jump to

Keyboard shortcuts

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