utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StandardTokenExpiration = 15             // StandardTokenExpiration minutes
	ExtendedTokenExpiration = (24 * 30) * 60 //30 days in minutes
	SecretLength            = 128 / 8        // 128 bits
)

Token expiration durations

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash checks a plaintext password with a hashed password

func GenerateJWTSecret

func GenerateJWTSecret() ([]byte, error)

Generate and use a new secret. The returned secret should be stored by the caller and passed to the LoadJWTSecret on each startup.

func GenerateJWTToken

func GenerateJWTToken(uuid string, expiration int64) (string, error)

GenerateJWTToken returns a JWT token based on the uuid, expiration and the secret sign

func HashPassword

func HashPassword(password string) string

HashPassword hashes the given password with bcrypt

func IsValidUUID

func IsValidUUID(u string) bool

IsValidUUID is a function that returns true if the input is a valid uuid. And false if the input isn't a valid uuid https://stackoverflow.com/a/46315070

func LoadJWTSecret

func LoadJWTSecret(secret []byte)

Use the given secret for generating and validating tokens

func QueryBuilder

func QueryBuilder(env *Env, r *http.Request) (storm.Query, error)

QueryBuilder is a method that generates storm query to give a more fine grain control over results Some query string examples that can be used filter example.com?format=[{key:value}] skip example.com?skip=10 limit example.com?limit=10 orderBy example.com?orderBy=Name,Age orderBy with reverse example.com?orderBy=Name,Age&reverse=true

func ValidateJWTToken

func ValidateJWTToken(tokenString string) (*jwt.StandardClaims, error)

ValidateJWTToken Returns if the given token is a valid token

Types

type Env

type Env struct {
	DataDir   string
	ConfigDir string
	Db        *storm.DB
	Validator *validator.Validate
}

type QueryBuilderParams

type QueryBuilderParams struct {
	//[{"key": "ID", "value": 1}] Array of values you want to filter
	Filter string `json:"filter"`
	// How many results it should skip
	Skip int `json:"skip"`
	// Max results returned
	Limit int `json:"limit"`
	// "Name, Age" Order by
	OrderBy []string `json:"orderBy"`
	// Reverse Order by
	Reverse bool `json:"reverse"`
}

swagger:parameters GetAllLogFiles GetAllCharts GetAllSheets GetAllWorkspaces

Jump to

Keyboard shortcuts

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