security

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAuthorized

func IsAuthorized(ctx *fasthttp.RequestCtx) bool

IsAuthorized compares the Authorization header to the master key. If they don't match, HTTP status code 401 is returned.

func Try

func Try(ctx context.Context, redisClient *redis.Client, id string, max int64, resetAfter int64, incrBy int64) (bool, error)

Try checks to see if the ID exceeds the max count specified. Additionally, a time to reset the limit and the increment amount is also specified. Based on https://github.com/etcinit/speedbump/blob/6ba8259841f7fb6dad77d2163bbf1c3794dc1853/speedbump.go#L99.

Types

type FilterStatus

type FilterStatus int
const (
	FilterPass FilterStatus = iota
	FilterFail
	FilterSanitize
)

func FilterCheck

func FilterCheck(ctx *fasthttp.RequestCtx, mimeType string) FilterStatus

FilterCheck runs the file's mime type through a series of checks. FilterPass means the mime type is fine and no additional action should be taken. FilterFail means a response was already returned, and the caller should terminate its function. FilterSanitize means the file's Content-Type header returned to the client should be changed to text/plain.

Jump to

Keyboard shortcuts

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