https://github.com/manifoldco/go-signature
Verify signed HTTP requests from Manifold
https://github.com/manifoldco/go-signature
Last synced: 3 months ago
JSON representation
Verify signed HTTP requests from Manifold
- Host: GitHub
- URL: https://github.com/manifoldco/go-signature
- Owner: manifoldco
- License: bsd-3-clause
- Created: 2017-04-03T16:06:55.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-01-13T15:19:34.000Z (over 5 years ago)
- Last Synced: 2025-05-08T08:03:23.916Z (5 months ago)
- Language: Go
- Homepage: https://www.manifold.co
- Size: 22.5 KB
- Stars: 5
- Watchers: 25
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# go-signature
Verify signed HTTP requests from Manifold
[Code of Conduct](./.github/CONDUCT.md) |
[Contribution Guidelines](./.github/CONTRIBUTING.md)[](https://github.com/manifoldco/go-signature/releases)
[](https://godoc.org/github.com/manifoldco/go-signature)
[](https://travis-ci.org/manifoldco/go-signature)
[](https://goreportcard.com/report/github.com/manifoldco/go-signature)
[](./LICENSE.md)## Usage
```go
import "github.com/manifoldco/go-signature"
```signature includes middleware that conforms to the http.Handler interface,
wrapping another http.Handler. If the request is invalid, the middleware will
respond directly, instead of calling your handler.Using the included middleware:
```go
verifier, _ := signature.NewVerifier(signature.ManifoldKey)
http.Handle("/v1", verifier.WrapFunc(func (rw http.ResponseWriter, r *http.Request) {
// your code goes here.
}))
```Verifying a request manually:
```go
body, err := ioutil.ReadAll(req.Body)
buf := bytes.NewBuffer(body)verifier, err := signature.NewVerifier(signature.ManifoldKey)
if err := verifier.Verify(req, buf); err != nil {
// return an error...
}// continue using the request and body
```Manual verification may be useful if you are not using a standard net/http
setup.