deskwapp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: GPL-3.0 Imports: 25 Imported by: 0

README

deskwapp

Helpful utilities to create web applications that run on your desktop machine to be accessed remotely by one user—most likely yourself!

Initial ideas were inspired by Syncthing which is an incredibly useful tool. That inspiration was needed for BC+—my Go-learning project back from the days when I liked to play ED very much. Then, when I published Gamcro to help out some people searching for something like that, I realized that a more in depth look at security was necessary. This Go module encapsulates what I learned from those efforts.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CryptRead

func CryptRead(rd io.Reader, g KeyGenerator, passwd []byte) ([]byte, error)

func CryptReadFile

func CryptReadFile(name string, g KeyGenerator, passwd []byte) ([]byte, error)

func CryptWrite

func CryptWrite(wr io.Writer, g KeyGenerator, passwd, data []byte) error

func CryptWriteFile

func CryptWriteFile(name string, g KeyGenerator, passwd, data []byte) error

func ReadAuthCreds

func ReadAuthCreds(rd io.Reader, ac *AuthCreds) (err error)

func ReadAuthCredsFile

func ReadAuthCredsFile(name string, ac *AuthCreds) error

func WriteAuthCreds

func WriteAuthCreds(wr io.Writer, ac *AuthCreds) (err error)

func WriteAuthCredsFile

func WriteAuthCredsFile(name string, ac *AuthCreds) error

Types

type Argon2idKeyGen

type Argon2idKeyGen struct {
	SaltSize    int
	KDFTime     uint32 // argon2.IDKey: 1
	KDFMemory   uint32 // argon2.IDKey: 64*1024
	KDFParallel uint8  // argon2.IDKey: 4
	KDFKeyLen   uint32
}

func (*Argon2idKeyGen) Generate

func (a2k *Argon2idKeyGen) Generate(passwd, salt []byte) (key, nsalt []byte, err error)

type AuthCreds

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

func NewAuthCreds

func NewAuthCreds(keyGen KeyGenerator) *AuthCreds

func (*AuthCreds) Check

func (ac *AuthCreds) Check(user string, passwd []byte) bool

func (*AuthCreds) CheckString

func (ac *AuthCreds) CheckString(user, passwd string) bool

func (*AuthCreds) Set

func (ac *AuthCreds) Set(user string, passwd []byte) (err error)

func (*AuthCreds) SetString

func (ac *AuthCreds) SetString(user, passwd string) (err error)

type BasicAuth

type BasicAuth struct {
	Realm        string
	Creds        *AuthCreds `json:"-"`
	FailMinDelay time.Duration
	FailMaxDelay time.Duration

	FailMsg    func(user string, rq *http.Request)
	SuccessMsg func(user string, rq *http.Request)
}

func (*BasicAuth) Protect

func (ba *BasicAuth) Protect(h http.HandlerFunc) http.HandlerFunc

func (*BasicAuth) SetRealm

func (ba *BasicAuth) SetRealm(from string) error

type CertConfig

type CertConfig struct {
	CommonName string
	Valid      time.Duration
}

type KeyGenerator

type KeyGenerator interface {
	// When salt is not nil, Generate takes passwd and salt and derives a key
	// from them returning also the given salt. If salt is nil, Generate first
	// creates a random salt and then derives the key returing also the new
	// salt.
	Generate(passwd, salt []byte) (key, nsalt []byte, err error)
}

type TLSServer

type TLSServer struct {
	Addr     string
	CertFile string
	KeyFile  string
	KeyGen   KeyGenerator
}

func (*TLSServer) HasCert

func (s *TLSServer) HasCert() bool

func (*TLSServer) ListenAndServe

func (s *TLSServer) ListenAndServe(passphrase []byte, handler http.Handler) error

Inspred by https://gist.github.com/tjamet/c9a53127c9bec54f62ed94685de85875

func (*TLSServer) NewCert

func (s *TLSServer) NewCert(passphrase []byte, cfg *CertConfig) (err error)

Jump to

Keyboard shortcuts

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