middlewares

package
v0.0.0-...-870cc59 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JWT = &jwt.GinJWTMiddleware{
	Realm:           "Gasper",
	Key:             []byte(configs.GasperConfig.Secret),
	Timeout:         configs.JWTConfig.Timeout * time.Second,
	MaxRefresh:      configs.JWTConfig.MaxRefresh * time.Second,
	TokenLookup:     "header: Authorization",
	TokenHeadName:   "Bearer",
	TimeFunc:        time.Now,
	Authenticator:   authenticator,
	PayloadFunc:     payloadFunc,
	IdentityHandler: identityHandler,
	Authorizator:    authorizator,
	Unauthorized:    unauthorized,
}

JWT handles the auth through JWT token

View Source
var JWTGctl = &jwt.GinJWTMiddleware{
	Realm:           "Gasper",
	Key:             []byte(configs.GasperConfig.Secret),
	Timeout:         configs.JWTConfig.Timeout * time.Second,
	MaxRefresh:      configs.JWTConfig.MaxRefresh * time.Second,
	TokenLookup:     "header: Authorization",
	TokenHeadName:   "gctlToken",
	TimeFunc:        time.Now,
	Authenticator:   authenticator,
	PayloadFunc:     payloadFuncForGctl,
	IdentityHandler: identityHandlerForGctl,
	Authorizator:    authorizatorForGctl,
	Unauthorized:    unauthorized,
}

JWTGctl handles the auth through JWT token for gctl

Functions

func AuthRequired

func AuthRequired() gin.HandlerFunc

AuthRequired returns middleware according to type of request

func ExtractClaims

func ExtractClaims(c *gin.Context) *types.User

ExtractClaims takes the gin context and returns the User

func IsAppOwner

func IsAppOwner(c *gin.Context)

IsAppOwner checks if a user is entitled to perform operations on an application

func IsDatabaseOwner

func IsDatabaseOwner(c *gin.Context)

IsDatabaseOwner checks if a user is entitled to perform operations on a database

func LoginHandler

func LoginHandler(c *gin.Context)

LoginHandler takes the gin context and executes LoginHandler function according to authorization type

func RefreshHandler

func RefreshHandler(c *gin.Context)

RefreshHandler takes the gin context and executes RefreshHandler function according to authorization type

func ValidateApplicationRequest

func ValidateApplicationRequest(c *gin.Context)

ValidateApplicationRequest validates the request for creating applications

func ValidateDatabaseRequest

func ValidateDatabaseRequest(c *gin.Context)

ValidateDatabaseRequest validates the request for creating databases

func ValidateRegistration

func ValidateRegistration(c *gin.Context)

ValidateRegistration validates the user registration request

func VerifyAdmin

func VerifyAdmin(c *gin.Context)

VerifyAdmin allows the request to proceed only if the user has admin privileges

Types

This section is empty.

Jump to

Keyboard shortcuts

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