Skip to content

prashant-agarwala/apiauth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

apiauth

ApiAuth-compatible package for signing and verifying HTTP requests in golang. It uses the same hmac authentication method (HMAC-SHA1)

Usage

Signing a request:

import 	"github.com/prashant-agarwala/apiauth"

req, _ := http.NewRequest("POST", "http://apiserver.com/api/v1/lists/create.json",payload)
err    := apiauth.Sign(req, "access_id", "secret_key")

Checking authenticity of a request:

Write your own method to find the associated secret_key against a access_id and pass it to the method Authentic. You can return any additional result which will be returned from Authentic method

import 	"github.com/prashant-agarwala/apiauth"

var getAPIKey apiauth.Finder = func(accessID string, request *http.Request) (string, interface{}, error) {
  return "secret_key", "result", nil
}

result, err := apiauth.Authentic(r, getAPIKey)

About

apiauth implementation in go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages