support

package module
v1.0.0 Latest Latest
Warning

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

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

README

nfcsupport

Support for a NFC base authentication tool.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NIterations = 50000 // # of iterations of hashing for passwords

Functions

func AddCookie

func AddCookie(w http.ResponseWriter, name, value string, inDays int)

addCookie will apply a new cookie to the response of a http request, with the key/value this method is passed.

func AddSecureCookie

func AddSecureCookie(w http.ResponseWriter, name, value string, inDays int)

func AnError

func AnError(www http.ResponseWriter, req *http.Request, httpStatus int, msg string)

AnError reports an error and logs the error to stderr.

func Exists

func Exists(name string) bool

Exists return true if the file/path or directory exists

func Fopen

func Fopen(fn string, mode string) (file *os.File, err error)

Fopen works like the C fopen - it opens a file based on mode and return sthe file

func GenRandBytes

func GenRandBytes(nRandBytes int) (buf []byte, err error)

Should move to aesccm package

func GenRandNumber

func GenRandNumber(nDigits int) (buf string)

Generate a random number, 0..N, returned as a string with 6 to 8 non-zero digits.

func GenUUID

func GenUUID() string

func GetCookie

func GetCookie(www http.ResponseWriter, req *http.Request, cookieName string) (val string)

func GetMultipleVar

func GetMultipleVar(name []string, www http.ResponseWriter, req *http.Request) (found bool, value map[string]string)

func GetParam

func GetParam(www http.ResponseWriter, req *http.Request, name string, dflt string) (rv string)

GetParam returns the named parameter from the URl or the defauilt value if not set.

func GetVar

func GetVar(name string, www http.ResponseWriter, req *http.Request) (found bool, value string)

GetVar returns a variable by name from GET or POST data.

func HaveCookie

func HaveCookie(www http.ResponseWriter, req *http.Request, cookieName string) bool

func IsTLS

func IsTLS(req *http.Request) bool

func RedisClient

func RedisClient(gCfg *RedisConfigType) (client *redis.Client, conFlag bool)

RedisClient makes a connection to the Redis datagbase and returns the client connection and a true/false flag. If the configuration includes an non-empty RedisConnectAuth then it will also do authenication with the AUTH command in the redis system.

func SVar

func SVar(v interface{}) string

SVar marshals data into a JSON string

func SVarI

func SVarI(v interface{}) string

SVarI marshals data into a JSON string with tab indentation

func SetCookie

func SetCookie(www http.ResponseWriter, req *http.Request, cookieName, value string, expireInDays int)

func SetSecureCookie

func SetSecureCookie(www http.ResponseWriter, req *http.Request, cookieName, value string, expireInDays int)

func SetSupport

func SetSupport(dbf map[string]bool, lfp *os.File)

Types

type RedisConfigType

type RedisConfigType struct {
	RedisConnectHost string `json:"redis_host" default:"$ENV$REDIS_HOST"`
	RedisConnectAuth string `json:"redis_auth" default:"$ENV$REDIS_AUTH"`
	RedisConnectPort string `json:"redis_port" default:"6379"`
}

type RedisConnection

type RedisConnection struct {
	TtlRedis int
	// contains filtered or unexported fields
}

---------------------------------------------------------------------------------------------------------------------- Redis interface ----------------------------------------------------------------------------------------------------------------------

func NewRedisConnection

func NewRedisConnection(gCfg *RedisConfigType) (rv *RedisConnection, err error)

func (*RedisConnection) CheckAuth

func (rCon *RedisConnection) CheckAuth(www http.ResponseWriter, req *http.Request) (ok bool)

CheckAuth Checks a X-Auth header authentication to validate a user. It returns true if the user is authorized, else it creates a 401 error and returns. func (rCon *RedisConnection) GetRedis(key string) (rv string, err error) {

func (*RedisConnection) CheckSetup

func (rCon *RedisConnection) CheckSetup()

CheckSetup checks to see if the Redis database has been initialized. If not -then it creates the necessary keys init.

func (*RedisConnection) CreateUser

func (rCon *RedisConnection) CreateUser(un, pw string) (err error)

CreateUser will create a user in Redis with a qr-auth: and qr-salt: keys.

func (*RedisConnection) DelRedis

func (rCon *RedisConnection) DelRedis(key string) (err error)

func (*RedisConnection) GetRedis

func (rCon *RedisConnection) GetRedis(key string) (rv string, err error)

GetRedis queries redis to return a value.

func (*RedisConnection) SetRedis

func (rCon *RedisConnection) SetRedis(key, data string) (err error)

SetRedis Sets `key` to value `data` in redis.

func (*RedisConnection) SetRedisTTL

func (rCon *RedisConnection) SetRedisTTL(key, data string, Ttl int) (err error)

SetRedis Sets `key` to value `data` in redis.

Jump to

Keyboard shortcuts

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