verifier

package module
v0.0.0-...-fb1cc50 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2020 License: MIT Imports: 12 Imported by: 0

README

Caddy Discord Interactions Verifier

If you use the Caddy web server (which provides features such as automatic TLS management and easy configuration) and are looking to host an endpoint for outgoing webhooks under Discord's recent Interactions feature, you're in luck! This Caddy module automatically verifies the Ed25519 signature in the body, and responds with a 401 before the request ever hits your handler if the signature doesn't match.

Installation

Install xcaddy, then run:

$ xcaddy build --with github.com/CarsonHoffman/caddy-discord-interactions-verifier

This will output an executable named caddy in your current directory, which you can use as the server executable, replacing your current Caddy executable if you have one (it might be found at /usr/bin/caddy).

Configuration

This module uses the discord Caddyfile directive. The only parameter is the hex representation of your Ed25519 public key (the representation given in the application portal). The following is a dead-simple example of a compatible Caddyfile, where our Ed25519 public key is 45a8bd39e8a146e201c2eb00e955c1484ebe4d87f8246b26dddff06d1728321a, the endpoint is hosted at the root of mydomain.com, and successfully-verified requests are proxied to another server at localhost:8080:

mydomain.com

route / {
  discord 45a8bd39e8a146e201c2eb00e955c1484ebe4d87f8246b26dddff06d1728321a
  reverse_proxy localhost:8080
}

That's the whole configuration! The discord directive is all you need to include, and it couldn't be simpler.


This module should help you get Discord Interactions up and running if you aren't as familiar with Ed25519 or signature schemes in general. Now go make something cool!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Verifier

type Verifier struct {
	PublicKeyHex string `json:"public_key"`
	// contains filtered or unexported fields
}

func (Verifier) CaddyModule

func (Verifier) CaddyModule() caddy.ModuleInfo

func (*Verifier) Provision

func (v *Verifier) Provision(ctx caddy.Context) error

func (Verifier) ServeHTTP

func (v Verifier) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*Verifier) UnmarshalCaddyfile

func (v *Verifier) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL