All Projects → averageflow → gohooks

averageflow / gohooks

Licence: MIT license
GoHooks make it easy to send and consume secured web-hooks from a Go application

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gohooks

sha-2
SHA-2 algorithm implementations
Stars: ✭ 122 (+662.5%)
Mutual labels:  secure, sha256
jscrypto
Crypto library for Node/ES6/Typescript/Browser.
Stars: ✭ 20 (+25%)
Mutual labels:  sha256
hookbot
Turn webhooks into websockets
Stars: ✭ 37 (+131.25%)
Mutual labels:  webhooks
ssh-keygen-web
Generate a key-pair of ssh-keygen on Web browser
Stars: ✭ 36 (+125%)
Mutual labels:  secure
akeneo-events-api-bundle
The Events API Bundle for Akeneo PIM delivers catalog changes as events to a 3rd party systems.
Stars: ✭ 18 (+12.5%)
Mutual labels:  webhooks
trobot
Make your own trello bot in node.js
Stars: ✭ 21 (+31.25%)
Mutual labels:  webhooks
ios-application
A native, lightweight and secure one-time-password (OTP) client built for iOS; Raivo OTP!
Stars: ✭ 581 (+3531.25%)
Mutual labels:  secure
lasso
Real-time UI for webhooks
Stars: ✭ 27 (+68.75%)
Mutual labels:  webhooks
hediye
Hash Generator & Cracker
Stars: ✭ 40 (+150%)
Mutual labels:  sha256
discord-webhooks
Provides easy to use bindings for the Discord Webhook API
Stars: ✭ 111 (+593.75%)
Mutual labels:  webhooks
linear-discord-serverless
Get linear's events forwarded to Discord webhooks through Vercel serverless functions.
Stars: ✭ 47 (+193.75%)
Mutual labels:  webhooks
simple-sha256
Generate SHA-256 hashes (in Node and the Browser)
Stars: ✭ 42 (+162.5%)
Mutual labels:  sha256
northstar
Embedded container runtime
Stars: ✭ 82 (+412.5%)
Mutual labels:  secure
otp-authenticator-webapp
A 'Google Authenticator' like Single Page Application
Stars: ✭ 69 (+331.25%)
Mutual labels:  secure
cryptosuite2
Cryptographic suite for Arduino (SHA, HMAC-SHA)
Stars: ✭ 23 (+43.75%)
Mutual labels:  sha256
convoy
Fast and Secure Webhooks Service.
Stars: ✭ 763 (+4668.75%)
Mutual labels:  webhooks
hash-wasm
Lightning fast hash functions using hand-tuned WebAssembly binaries
Stars: ✭ 382 (+2287.5%)
Mutual labels:  sha256
encrypted-smiley-secure-protocol
Node.JS library Encrypted Smiley ® Secure Protocol (eSSP, SSP)
Stars: ✭ 22 (+37.5%)
Mutual labels:  secure
SecureFiware
Proposing security measures and security analysis in the Fiware IoT environment.
Stars: ✭ 21 (+31.25%)
Mutual labels:  secure
ipvpn
[WIP] Easy-to-use decentralized secure overlay private network (for any device)
Stars: ✭ 24 (+50%)
Mutual labels:  secure

GoHooks

Mentioned in Awesome Go
PkgGoDev Build Size Maintainability codecov Go Report Card License Issues

GoHooks make it easy to send and consume secured web-hooks from a Go application. A SHA-256 signature is created with the sent data plus an encryption salt and serves to validate on receiving, effectively making your applications only accept communication from a trusted party.

Installation

Add github.com/averageflow/gohooks/v2 to your go.mod file and then import it into where you want to be using the package by using:

import (
    "github.com/averageflow/gohooks/v2/gohooks"
)

Usage

Here I will list the most basic usage for the GoHooks. If you desire more customization please read the section below for more options.

Sending

The most basic usage for sending is:

// Data can be any type, accepts interface{}
data := []int{1, 2, 3, 4} 
// String sent in the GoHook that helps identify actions to take with data
resource := "int-list-example"
// Secret string that should be common to sender and receiver
// in order to validate the GoHook signature
saltSecret := "0014716e-392c-4120-609e-555e295faff5"

hook := &gohooks.GoHook{}
hook.Create(data, resource, salt)

// Will return *http.Response and error
resp, err := hook.Send("www.example.com/hooks")

Receiving

The most basic usage for receiving is:

type MyWebhook struct {
    Resource string `json:"resource"`
    Data []int `json:"data"`
}

var request MyWebhook
// Assuming you use Gin Gonic, otherwise unmarshall JSON yourself.
_ = c.ShouldBindJSON(&request)

// Shared secret with sender
saltSecret := "0014716e-392c-4120-609e-555e295faff5"
// Assuming you use Gin Gonic, obtain signature header value
receivedSignature := c.GetHeader(gohooks.DefaultSignatureHeader)

// Verify validity of GoHook
isValid := gohooks.IsGoHookValid(request, receivedSignature, saltSecret)
// Decide what to do if GoHook is valid or not.

Customization

GoHooks use the custom header X-GoHooks-Verification to send the encrypted SHA string. You can customize this header by initializing the GoHook struct with the custom option SignatureHeader.

Example:

hook := &gohooks.GoHook{ SignatureHeader: "X-Example-Custom-Header" }

GoHooks are by default not verifying the receiver's SSL certificate validity. If you desire this behaviour then enable it by initializing the GoHook struct with the custom option IsSecure.

Example:

hook := &gohooks.GoHook{ IsSecure: true }

GoHooks will by default be sent via a POST request. If you desire to use a different HTTP method, amongst the allowed POST, PUT, PATCH, DELETE, then feel free to pass that option when initializing the GoHook struct, with PreferredMethod. Any other value will make the GoHook default to a POST request.

Example:

hook := &gohooks.GoHook{ PreferredMethod: http.MethodDelete }

GoHooks can be sent with additional HTTP headers. If you desire this then initialize the GoHook struct with the custom option AdditionalHeaders.

Example:

hook := &gohooks.GoHook{ AdditionalHeaders: map[string]string{"X-Header-Test": "Header value"} }

If you want to send your payload without GoHooks modifying it into its struct, use CreateWithoutWrapper when creating the GoHook.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].