SecREST

package module
v0.0.0-...-5879c16 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: LGPL-3.0 Imports: 8 Imported by: 0

README

SecREST

A secure REST wrapper around gorilla/mux

Badges

GPLv3 License Build Status Go Report Card Documentation

Acknowledgements

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Handlers that will be called for internall routing after de/encryption
	Handlers []SecRESTHandler
	// Auth handler
	Auth SecRESTAuth
	// SERVER public key, armored
	PubKey string
	// SERVER private key, armored
	PrivKey string
	// Password for SERVER private key
	KeyPass string
	// AuthClients is intentionally made non-persistent, expires all clients on reboot.
	// This however is open for debate.
	AuthClients = make(map[string]string)
)

Functions

func StartRouter

func StartRouter(port string, pubKey string, privKey string, keyPass string, handlers []SecRESTHandler, auth SecRESTAuth)

StartRouter accepts a Port string, and a slice of SecRESTHandler

then starts the router.

Types

type SecRESTAuth

type SecRESTAuth struct {
	// Handle Authentication for new client
	Run func(w http.ResponseWriter, r *http.Request) (bool, SecRESTAuthRequest)
}

SecRESTAuth struct is for authenticating a client, and storing their PGP key

type SecRESTAuthRequest

type SecRESTAuthRequest struct {
	ClientKey string `json:"ClientKey"`
}

type SecRESTAuthResponse

type SecRESTAuthResponse struct {
	ServerKey        string `json:"ServerKey"`
	ClientIdentifier string `json:"ClientIdentifier"`
}

type SecRESTHandler

type SecRESTHandler struct {
	Path     string
	Insecure bool
	Body     string
	Run      func(SecRESTRequest) SecRESTResponse
}

Struct for handlers, Insecure = True allows /insecure access

type SecRESTRequest

type SecRESTRequest struct {
	Path             string `json:"Path"`
	Body             string `json:"Body"`
	ClientIdentifier string `json:"ClientIdentifier"`
	Insecure         bool
	TimeStamp        time.Time          `json:"TimeStamp"`
	AuthRequest      SecRESTAuthRequest `json:"AuthRequest"`
}

SecRESTRequest is a decrypted request coming in from a client

type SecRESTResponse

type SecRESTResponse struct {
	Status       int                 `json:"Status"`
	Body         string              `json:"Body"`
	Ellapsed     string              `json:"Ellapsed"`
	AuthResponse SecRESTAuthResponse `json:"AuthResponse"`
}

SecRESTResponse is a decrypted response to be sent to the client Will be encrypted if request.Insecure = false

Jump to

Keyboard shortcuts

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