sigchecker

package module
v0.0.0-...-feb8f9a Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2015 License: MIT Imports: 6 Imported by: 1

README

sigchecker

an signature checker middleware for go-json-rest

purpose

some API services only provided for authorized clients, this middleware verify an signature in request header, both client side and server side must use same secret key to generate/check signature

install


go get -u github.com/zx9597446/sigchecker

use this middleware with go-json-rest

	secret := "abcd"
	headerKey := "X-request-signature"
	api := rest.NewApi()
	api.Use(rest.DefaultDevStack...)
	api.Use(NewSignatureChecker(headerKey, secret))

how to make request on client side

formation of signature in request header is:

timestamp,signature

to generate signature:

signature = md5(timestamp + secret)

API doc

see doc

examples

see test

Documentation

Overview

Package sigchecker provides ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SignatureChecker

type SignatureChecker struct {
	HeaderKey string
	Secret    string
}

SignatureChecker verifies the request header signature it returns http.StatusUnauthorized if failed check

func NewSignatureChecker

func NewSignatureChecker(headerKey, secret string) *SignatureChecker

helper function to make new SignatureChecker

func (*SignatureChecker) MiddlewareFunc

func (mw *SignatureChecker) MiddlewareFunc(handler rest.HandlerFunc) rest.HandlerFunc

MiddlewareFunc makes SignatureChecker implement the Middleware interface.

Jump to

Keyboard shortcuts

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