Documentation
¶
Index ¶
- Constants
- Variables
- func Auth(c *fiber.Ctx) (jwt.Claims, error)
- func CheckAuth(ctx context.Context, roles []int) (jwt.MapClaims, error)
- func CheckColumns(column string, columns []string) error
- func DefaultSkipper(*fiber.Ctx) bool
- func Filter(filtersPre interface{}, query *gorm.DB, columns []string) (*gorm.DB, error)
- func GetNestedPreloads(ctx *graphql.OperationContext, fields []graphql.CollectedField, prefix string) (preloads []string)
- func GetPaginationTargetAndColumns(ctx context.Context) (string, []string, error)
- func GetPreloadString(prefix, name string) string
- func GetPreloads(ctx context.Context) []string
- func GetRole(role interface{}) int
- func GroupFilter(filterGroupsPre interface{}, queryMain *gorm.DB, columns []string) (*gorm.DB, error)
- func IsLoggedIn(c *fiber.Ctx) (jwt.Claims, error)
- func JWTFromCookie(name string, c *fiber.Ctx) (string, error)
- func JWTFromHeader(header string, authScheme string, c *fiber.Ctx) (string, error)
- func Order(sortsPre interface{}, query *gorm.DB, columns []string) (*gorm.DB, error)
- func ParseToken(auth string, c *fiber.Ctx) (jwt.Claims, error)
- func Process() fiber.Handler
- func RandString(n int) string
- func RemoveDuplicate(intSlice []string) []string
- type BeforeFunc
- type CustomContext
- type JWTConfig
- type JWTErrorHandler
- type JWTErrorHandlerWithContext
- type JWTSuccessHandler
- type Skipper
- type Sub
Constants ¶
View Source
const (
AlgorithmHS256 = "HS256"
)
View Source
const FiberContextKey = "FiberContextKey"
Variables ¶
View Source
var JWTconfig = JWTConfig{ Skipper: DefaultSkipper, SigningMethod: AlgorithmHS256, ContextKey: "user", TokenLookup: "header:Authorization,", AuthScheme: "Bearer", Claims: jwt.MapClaims{}, }
Functions ¶
func CheckColumns ¶
func DefaultSkipper ¶
func DefaultSkipper(*fiber.Ctx) bool
func GetNestedPreloads ¶
func GetNestedPreloads(ctx *graphql.OperationContext, fields []graphql.CollectedField, prefix string) (preloads []string)
func GetPreloadString ¶
func GetPreloads ¶
func GroupFilter ¶
func IsLoggedIn ¶
func IsLoggedIn(c *fiber.Ctx) (jwt.Claims, error)
func JWTFromCookie ¶
func JWTFromHeader ¶
func ParseToken ¶
func RandString ¶
func RemoveDuplicate ¶
Types ¶
type BeforeFunc ¶
type BeforeFunc func(*fiber.Ctx)
BeforeFunc defines a function which is executed just before the middleware.
type CustomContext ¶
type CustomContext struct {
*fiber.Ctx
// contains filtered or unexported fields
}
type JWTConfig ¶
type JWTConfig struct {
// Skipper defines a function to skip middleware.
Skipper Skipper
// BeforeFunc defines a function which is executed just before the middleware.
BeforeFunc BeforeFunc
// SuccessHandler defines a function which is executed for a valid token.
SuccessHandler JWTSuccessHandler
// ErrorHandler defines a function which is executed for an invalid token.
// It may be used to define a custom JWT error.
ErrorHandler JWTErrorHandler
// ErrorHandlerWithContext is almost identical to ErrorHandler, but it's passed the current context.
ErrorHandlerWithContext JWTErrorHandlerWithContext
// Signing key to validate token. Used as fallback if SigningKeys has length 0.
// Required. This or SigningKeys.
SigningKey interface{}
// Map of signing keys to validate token with kid field usage.
// Required. This or SigningKey.
SigningKeys map[string]interface{}
// Signing method, used to check token signing method.
// Optional. Default value HS256.
SigningMethod string
// Context key to store user information from the token into context.
// Optional. Default value "user".
ContextKey string
// Claims are extendable claims data defining token content.
// Optional. Default value jwt.MapClaims
Claims jwt.Claims
// TokenLookup is a string in the form of "<source>:<name>" that is used
// to extract token from the request.
// Optional. Default value "header:Authorization".
// Possible values:
// - "header:<name>"
// - "query:<name>"
// - "param:<name>"
// - "cookie:<name>"
TokenLookup string
// AuthScheme to be used in the Authorization header.
// Optional. Default value "Bearer".
AuthScheme string
// contains filtered or unexported fields
}
JWTConfig defines the config for JWT middleware.
type JWTErrorHandler ¶
JWTErrorHandler defines a function which is executed for an invalid token.
type JWTErrorHandlerWithContext ¶
JWTErrorHandlerWithContext is almost identical to JWTErrorHandler, but it's passed the current context.
type JWTSuccessHandler ¶
type JWTSuccessHandler func(*fiber.Ctx)
JWTSuccessHandler defines a function which is executed for a valid token.
Click to show internal directories.
Click to hide internal directories.