Documentation ¶
Overview ¶
Package middleware contains: - CORS - Application firewall - Pongo2 template engine - JWT - Sentry logger - Two-factor auth validator
Index ¶
- func CORS(cp []CORSPolicy) gin.HandlerFunc
- func Firewall(listType string, ipList string) gin.HandlerFunc
- func GetJWT(customClaims MyCustomClaims, tokenType string) (string, string, error)
- func JWT() gin.HandlerFunc
- func Pongo2(baseDirectory string) gin.HandlerFunc
- func RefreshJWT() gin.HandlerFunc
- func SentryCapture(sentryDsn string) gin.HandlerFunc
- func TwoFA(keywordOn, keywordOff, keywordVerified string) gin.HandlerFunc
- type CORSPolicy
- type JWTClaims
- type JWTParameters
- type JWTPayload
- type MyCustomClaims
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Firewall ¶ added in v1.4.0
func Firewall(listType string, ipList string) gin.HandlerFunc
Firewall - whitelist/blacklist IPs
func GetJWT ¶
func GetJWT(customClaims MyCustomClaims, tokenType string) (string, string, error)
GetJWT - issue new tokens
func Pongo2 ¶ added in v1.4.0
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 ¶ added in v1.2.5
func RefreshJWT() gin.HandlerFunc
RefreshJWT - validate refresh token
func SentryCapture ¶ added in v1.2.4
func SentryCapture(sentryDsn string) gin.HandlerFunc
SentryCapture - capture errors and forward to sentry.io
func TwoFA ¶ added in v1.6.1
func TwoFA(keywordOn, keywordOff, keywordVerified string) gin.HandlerFunc
TwoFA validates 2-FA status from JWT before forwarding the request to the controller
Types ¶
type CORSPolicy ¶ added in v1.6.2
CORSPolicy struct to handle all policies
type JWTClaims ¶ added in v1.5.1
type JWTClaims struct { MyCustomClaims jwt.StandardClaims }
JWTClaims ...
type JWTParameters ¶ added in v1.6.1
type JWTParameters struct { AccessKey []byte AccessKeyTTL int RefreshKey []byte RefreshKeyTTL int Audience string Issuer string AccNbf int RefNbf int Subject string }
JWTParameters - params to configure JWT
var JWTParams JWTParameters
JWTParams - exported variables
type JWTPayload ¶ added in v1.2.5
type JWTPayload struct { AccessJWT string `json:"accessJWT,omitempty"` RefreshJWT string `json:"refreshJWT,omitempty"` }
JWTPayload ...
type MyCustomClaims ¶
type MyCustomClaims struct { AuthID uint64 `json:"authID,omitempty"` Email string `json:"email,omitempty"` Role string `json:"role,omitempty"` Scope string `json:"scope,omitempty"` TwoFA string `json:"twoFA,omitempty"` SiteLan string `json:"siteLan,omitempty"` Custom1 string `json:"custom1,omitempty"` Custom2 string `json:"custom2,omitempty"` }
MyCustomClaims ...