utilities

package
v0.0.0-...-cb6fcfe Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ServeHost string
	ServePort string
	ApiBase   string

	DbMigration bool
)

Functions

func CleanString

func CleanString(in string) string

func GetCommonMiddleware

func GetCommonMiddleware() *negroni.Negroni

func GetJWTMiddleware

func GetJWTMiddleware() *jwtmiddleware.JWTMiddleware

func GetProtectionMiddleware

func GetProtectionMiddleware() *negroni.Negroni

func GetUserScopes

func GetUserScopes(user string) (scopes []string)

func LoadConfig

func LoadConfig()

func PrepareMiddleware

func PrepareMiddleware()

func PrintErrors

func PrintErrors(errMsg string, errs []error) bool

func ProfileFromToken

func ProfileFromToken(r *http.Request) map[string]interface{}

profileFromToken will extract the user profile from the request JWT token. This contains data used to validate the user against an eagate account.

func RespondWithError

func RespondWithError(rw http.ResponseWriter, err bst_models.Error)

func UserHasScopes

func UserHasScopes(user string, scopes []string) bool

func ValidateFiltering

func ValidateFiltering(i interface{}, filterRequest []string) (filtering string)

ValidateFiltering will ensure filtered select statements will only use valid rows from the interface. TODO: Do validation on clauses.

func ValidateOrdering

func ValidateOrdering(i interface{}, orderRequest []string) (ordering string)

ValidateOrdering will ensure columns in orderRequest are correct for the provided interfae. Additionally, it will only allow ASC and DESC. TODO: support fields such as LENGTH(id)

Types

type JSONWebKeys

type JSONWebKeys struct {
	Kty string   `json:"kty"`
	Kid string   `json:"kid"`
	Use string   `json:"use"`
	N   string   `json:"n"`
	E   string   `json:"e"`
	X5c []string `json:"x5c"`
}

type Jwks

type Jwks struct {
	Keys []JSONWebKeys `json:"keys"`
}

type Response

type Response struct {
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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