webserver

package
v0.0.0-...-b63ba6b Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OtpToken

type OtpToken struct {
	Token  string `json:"token,omitempty"`
	Secret string `json:"secret,omitempty"`
}

OtpToken reprensent the One Time Password token AND secret

type UI

type UI struct {
	// contains filtered or unexported fields
}

UI is the interface/struct for the web server (excluding the APIs)

func New

func New() *UI

New return a new UI struct. It's already set up and have create a new *local* api.

func (*UI) GenerateOTPSecret

func (ui *UI) GenerateOTPSecret(w http.ResponseWriter, req *http.Request)

GenerateOTPSecret generates a new secrets (80 bit base32 encoded) FIXME: Shouldn't this only be done client side ? Maybe dont trust client side crypto ? idk

func (*UI) HandleIndex

func (ui *UI) HandleIndex(w http.ResponseWriter, req *http.Request)

HandleIndex differenciate request to be able to send the correct response If there is no subdomain, send the user interface (React app) Else, return the payload (if it exist, otherwise 404)

func (*UI) HandlePayloadByID

func (ui *UI) HandlePayloadByID(w http.ResponseWriter, req *http.Request)

HandlePayloadByID Serve payload by its ID (used only in subpath)

func (*UI) LoggingMiddleware

func (ui *UI) LoggingMiddleware(next http.Handler) http.Handler

LoggingMiddleware print all the http requests done by the application on a standard format

func (*UI) Login

func (ui *UI) Login(w http.ResponseWriter, req *http.Request)

Login is the http handler function for user login

func (*UI) Logout

func (ui *UI) Logout(w http.ResponseWriter, r *http.Request)

Logout is the http handler function. Login out with JWT is a bit tricky since there is no real way of invalidating a JWT. We might want to add blacklisting but it's overkill for this usage IMO There MUST be an enforcement in the validity duration of each token tho.

func (*UI) RegisterOTP

func (ui *UI) RegisterOTP(w http.ResponseWriter, req *http.Request)

RegisterOTP recieve a new shared secret for TOTP and saves it for a given user

func (*UI) Routes

func (ui *UI) Routes(router *mux.Router)

Routes defines the non-api routes (User interface and Payload serving using path)

func (*UI) Serve

func (ui *UI) Serve(router *mux.Router)

Serve run the webserve on http & https (if enabled)

func (*UI) ServeUI

func (ui *UI) ServeUI(w http.ResponseWriter, r *http.Request)

ServeUI render the React APP TODO: use bindata to embed it in the golang binary

Jump to

Keyboard shortcuts

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