Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stremovskyy/httpsign
gin httpsign duplicate with some improvements
https://github.com/stremovskyy/httpsign
Last synced: 4 days ago
JSON representation
gin httpsign duplicate with some improvements
- Host: GitHub
- URL: https://github.com/stremovskyy/httpsign
- Owner: stremovskyy
- License: mit
- Created: 2021-03-09T15:44:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T12:14:13.000Z (over 1 year ago)
- Last Synced: 2024-06-21T18:12:12.784Z (5 months ago)
- Language: Go
- Size: 35.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpsign
Duplicated from [gin-contrib / httpsign](https://github.com/gin-contrib/httpsign)
Signing HTTP Messages Middleware base on [HTTP Signatures](https://tools.ietf.org/html/draft-cavage-http-signatures).
## Example
``` go
package main
import (
"github.com/stremovskyy/httpsign"
"github.com/stremovskyy/httpsign/crypto"
"github.com/gin-gonic/gin"
)func main() {
// Define algorithm
hmacsha256 := &crypto.HmacSha256{}
hmacsha512 := &crypto.HmacSha512{}
// Init define secret params
readKeyID := httpsign.KeyID("read")
writeKeyID := httpsign.KeyID("write")
secrets := httpsign.Secrets{
readKeyID: &httpsign.Secret{
Key: "HMACSHA256-SecretKey",
Algorithm: hmacsha256, // You could using other algo with interface Crypto
},
writeKeyID: &httpsign.Secret{
Key: "HMACSHA512-SecretKey",
Algorithm: hmacsha512,
},
}// Init server
r := gin.Default()//Create middleware with default rule. Could modify by parse Option func
auth := httpsign.NewAuthenticator(secrets)r.Use(auth.Authenticated())
r.GET("/a", a)
r.POST("/b", b)
r.POST("/c", c)r.Run(":8080")
}```