middleware

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AccessKey     []byte
	AccessKeyTTL  int
	RefreshKey    []byte
	RefreshKeyTTL int

	Audience string
	Issuer   string
	AccNbf   int
	RefNbf   int
	Subject  string
)

variables for issuing or validating tokens

View Source
var (
	AuthID  uint64
	Email   string
	Role    string
	Scope   string
	SiteLan string
	Custom1 string
	Custom2 string
)

user-related info for JWT

Functions

func CORS

func CORS(origin, credentials, headers, methods, maxAge string) gin.HandlerFunc

CORS - Cross-Origin Resource Sharing origin: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin credentials: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Credentials headers: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Headers methods: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Methods maxAge: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age General recommendation for dev environment: ---------------------------------- origin: "*" credentials: "true" headers: "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, accept, origin, Cache-Control, X-Requested-With" methods: "GET, POST, PUT, PATCH, DELETE" maxAge: 300

func Firewall

func Firewall(listType string, ipList string) gin.HandlerFunc

Firewall - whitelist/blacklist IPs

func GetJWT

func GetJWT(id uint64, email, role, scope, siteLan, custom1, custom2, tokenType string) (string, string, error)

GetJWT - issue new tokens

func JWT

func JWT() gin.HandlerFunc

JWT - validate access token

func Pongo2

func Pongo2(baseDirectory string) gin.HandlerFunc

Pongo2 - uses the Pongo2 template library https://github.com/flosch/pongo2 to render templates Example: baseDirectory = "templates/"

func RefreshJWT

func RefreshJWT() gin.HandlerFunc

RefreshJWT - validate refresh token

func SentryCapture

func SentryCapture(sentryDsn string) gin.HandlerFunc

SentryCapture - capture errors and forward to sentry.io

Types

type JWTClaims added in v0.0.3

type JWTClaims struct {
	jwt.StandardClaims
	// contains filtered or unexported fields
}

JWTClaims ...

type JWTPayload

type JWTPayload struct {
	AccessJWT  string `json:"accessJWT,omitempty"`
	RefreshJWT string `json:"refreshJWT,omitempty"`
}

JWTPayload ...

Jump to

Keyboard shortcuts

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