Documentation ¶
Index ¶
- func AutoMigrateSQL(pg_conn *gorm.DB, inf ...interface{})
- func BindJson(c *gin.Context, obj interface{}, appName string) bool
- func BindURI(c *gin.Context, obj interface{}, appName string) bool
- func CORS(c *gin.Context)
- func CheckEmail(value string) bool
- func CheckError(c *gin.Context, err *error, appName string) bool
- func CheckPassword(c *gin.Context, hash, password *string) bool
- func CheckSession(ctx *context.Context, c *gin.Context, userID, token *string, ...) bool
- func CheckString(testString string, minLength, maxLength uint32, asciiOnly bool) bool
- func CheckStringFull(testString string, minLength, maxLength uint32) (minSize bool, maxSize bool, ascii bool)
- func CheckStringR(parameter *string, paramName string, minLength, maxLength uint32, ...) (bool, string)
- func CheckToken(c *gin.Context, stringOne, stringTwo *string) bool
- func CoffeOut(c *gin.Context)
- func ComparePasswordAndHash(password, encodedHash *string) (match bool, err error)
- func ConfigRouter(router *gin.Engine, trustedProxy []string)
- func ConnectRedis(ctx context.Context, dbNumber int) *redis.Client
- func ConnectSQL() *gorm.DB
- func CountDB(c *gin.Context, pg_conn *gorm.DB, model interface{}, condition interface{}) (int64, error)
- func CreateHash(password *string) (string, error)
- func CreateSession(ctx *context.Context, userID *string, redisClient *redis.Client, ...) (string, string, error)
- func DecodeHash(encodedHash *string) (params usedHashParams, err error)
- func DeleteDB(c *gin.Context, pg_conn *gorm.DB, condition interface{}, inf interface{}) bool
- func ErrorFatal(name string, err error)
- func ErrorPanic(err error)
- func ExistsDB(c *gin.Context, pg_conn *gorm.DB, model interface{}, condition interface{}) (bool, error)
- func GetDB(c *gin.Context, pg_conn *gorm.DB, condition interface{}, inf interface{}) bool
- func GetHealth(c *gin.Context)
- func GetUUID() string
- func ImTeaPot(c *gin.Context)
- func IsASCII(s string) bool
- func JsonRequested(c *gin.Context, appName string) bool
- func LogError(name string, err error)
- func LogEvent(name string, message string)
- func RandomBytes(length uint32) ([]byte, error)
- func RandomString(length uint32) (string, error)
- func RandomStringCompare(stringOne, stringTwo *string) (bool, error)
- func Redirect(url string) gin.HandlerFunc
- func SetupUUID()
- func StartRouter(router *gin.Engine, bind string)
- func StoreDB(c *gin.Context, pg_conn *gorm.DB, inf interface{}) bool
- func UpdateDB(c *gin.Context, pg_conn *gorm.DB, condition interface{}, inf interface{}) bool
- func ValidateCaptcha(c *gin.Context, secret string, response *string, hostname string, ...) (bool, bool)
- func ValidateSession(ctx *context.Context, uid, token *string, redisClient *redis.Client, ...) (bool, error)
- type HCaptchaResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoMigrateSQL ¶
migrates all tables, panics on error
func BindJson ¶
bind the received json to the given struct, sets the status to 400 if false, 406 if no json was requested
func CheckError ¶
returns true if an error happened, sets the status to 500 if true
func CheckPassword ¶
checks if the password matches the hash, sets the HTTP code to 500 on DB failure / 401 if the password is wrong
func CheckSession ¶
func CheckSession(ctx *context.Context, c *gin.Context, userID, token *string, redisClient *redis.Client, sessionTime time.Duration) bool
checks if the session is valid, sets the HTTP code to 500 on DB error / 401 on non-valid if false
func CheckString ¶
returns true if all parameters are true
func CheckStringFull ¶
func CheckStringFull(testString string, minLength, maxLength uint32) (minSize bool, maxSize bool, ascii bool)
returns false if a given parameter is false, minSize, maxSize, ascii TODO: Test
func CheckStringR ¶
func CheckStringR(parameter *string, paramName string, minLength, maxLength uint32, asciiOnly bool) (bool, string)
checks the string and generates an error message
func CheckToken ¶
checks if both token match, sets the HTTP code to 400 on encoding failure / 401 on token miss match
func ComparePasswordAndHash ¶
func ConfigRouter ¶
configures the Trusted proxies list
func ConnectRedis ¶
connects to the redis server specified in ENV, tests the connection
func CountDB ¶
func CountDB(c *gin.Context, pg_conn *gorm.DB, model interface{}, condition interface{}) (int64, error)
returns the number of rows with the given condition
func CreateHash ¶
func CreateSession ¶
func CreateSession(ctx *context.Context, userID *string, redisClient *redis.Client, keyLength uint32, maxSessions int, sessionDuration time.Duration) (string, string, error)
creates a new session in the given redis DB adds the session number to the UserID to keep the session ID unique returns sessionID, sessionKey, err
func DecodeHash ¶
func ErrorFatal ¶
func ErrorPanic ¶
func ErrorPanic(err error)
func ExistsDB ¶
func ExistsDB(c *gin.Context, pg_conn *gorm.DB, model interface{}, condition interface{}) (bool, error)
returns true if an entry for the given condition exists
func GetDB ¶
Finds and Returns true with the Data Entry or false if not found, sets status to 500 (error) or 404 (not found) if false
func JsonRequested ¶
returns true, if the client requested json format, also sets the response to 406, if not
func RandomBytes ¶
func RandomString ¶
func RandomStringCompare ¶
decodes the strings and cryptographically compares them, returns true if they match
func SetupUUID ¶
func SetupUUID()
enables using the random pool, might be insecure and isn't thread safe
func StartRouter ¶
starts the router on the given IP and port
func UpdateDB ¶
Finds Data Entry with condition and updates it with new data, sets status to 500 if false
Types ¶
type HCaptchaResponse ¶
type HCaptchaResponse struct { Success bool `json:"success"` ChallengeTS time.Time `json:"challenge_ts"` Hostname string `json:"hostname"` Credit bool `json:"credit"` ErrorCode []string `json:"error-codes"` }
func (*HCaptchaResponse) Get ¶
func (hresp *HCaptchaResponse) Get(secret, response *string) error
retrieves the HCaptcha response