Skip to content

🚀 A simple webhook server with just enough security to keep honest people honest. Trigger shell scripts with http calls!

Notifications You must be signed in to change notification settings

jeffjyang/go-webhook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-webhook

A dead simple webhook server with support for TOTP authentication (OTP codes generated by a 2FA app such as Google Authenticator).

Built with the intention of being used as a simple deployment service for personal and school projects.

TOTP authentication added to discourage curious people from messing with your system. Just enough to keep honest people honest!

Basic Usage

To run the server:

$ ./go-webhook -h
Usage of ./go-webhook:
  -otp-secret string
    	Base32 encoded secret code for OTP authentication. Set this value only if you wish to enable OTP authentication.
  -port string
    	Server port (default "8080") 
# Examples: 
$ ./go-webhook 
$ ./go-webhook -port=5000 -otp-secret=4S62BZNFXXSZLCRO

Endpoints:

The endpoints for the server are determined by the script files present in the directory that the go binary is executed from. All endpoints will be in the form path/<scriptFile.sh>

Interacting with the server can be done through your browser's address bar, simply by going to the appropriate endpoint:

Run the shell script and wait for its completion:

$ curl http://localhost:8080/webhook/run/script.sh
Script output:

Hello bash!

Run the shell script but don't wait for completion:

$ curl http://localhost:8080/webhook/async/script.sh
Triggered script: script.sh

Get the timestamp and output of the last script execution:

$ curl http://localhost:8080/webhook/log/script.sh
Script script.sh last executed at:

Thu Apr  2 10:15:10 PDT 2020

Output:

Hello bash!

OTP authentication:

If OTP authentication is enabled, simply append ?otp=<your OTP code> to the end of the url to authenticate. OTP authentication will be required for every endpoint.

Authenticating write a valid OTP:

$ curl http://localhost:8080/webhook/run/script.sh?otp=123456
Script output:

Hello bash!

If an invalid OTP is provided:

$ curl http://localhost:8080/webhook/run/script.sh?otp=123456
Unauthorized. 

About

🚀 A simple webhook server with just enough security to keep honest people honest. Trigger shell scripts with http calls!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published