middleware

package
v0.0.0-rc8 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthUserKey = "authUser"
)

Variables

View Source
var (
	ErrJwtTokenIsMissing = dto.NewI18nError("JWT token is missing", "errors.session_invalid")
	ErrInvalidJwtToken   = dto.NewI18nError("invalid JWT token", "errors.session_invalid")
	ErrExpiredJwtToken   = dto.NewI18nError("expired JWT token", "errors.session_expired")
	ErrBannedJwtToken    = dto.NewI18nError("banned JWT token", "errors.session_banned")
	ErrUserNotFound      = dto.NewI18nError("user not found", "errors.user_not_found")
)
View Source
var (
	LangKey      = "lang"
	LocalizerKey = "localizer"
)
View Source
var (
	ErrAccessDenied = dto.NewI18nError("access denied", "errors.access_denied")
)
View Source
var (
	ErrBannedUser = dto.NewI18nError("banned user", "errors.banned_user")
)
View Source
var (
	ErrDeletedUser = dto.NewI18nError("deleted user", "errors.deleted_user")
)
View Source
var (
	ErrTooManyRequests = dto.NewI18nError("too many requests", "errors.too_many_requests")
)

Functions

func BannedUserMiddleware

func BannedUserMiddleware() gin.HandlerFunc

BannedUserMiddleware

Use strictly after adding JWT middleware

func CorsMiddleware

func CorsMiddleware() gin.HandlerFunc

func DeletedUserMiddleware

func DeletedUserMiddleware() gin.HandlerFunc

DeletedUserMiddleware

Use strictly after adding JWT middleware

func ErrorMiddleware

func ErrorMiddleware() gin.HandlerFunc

func JWTMiddleware

func JWTMiddleware(cfg config.JWTConfig, bannedTokenRepo repo.BannedTokenRepository) gin.HandlerFunc

func LocaleMiddleware

func LocaleMiddleware(bundle *i18n.Bundle) gin.HandlerFunc

func LoggerMiddleware

func LoggerMiddleware() gin.HandlerFunc

func MemoryRateLimitMiddleware

func MemoryRateLimitMiddleware(rps int) gin.HandlerFunc

func RecoveryMiddleware

func RecoveryMiddleware() gin.HandlerFunc

func RedisRateLimitMiddleware

func RedisRateLimitMiddleware(redisClient redis.UniversalClient, rps int) gin.HandlerFunc

func RoleMiddleware

func RoleMiddleware(roles ...string) gin.HandlerFunc

func SecurityHeadersMiddleware

func SecurityHeadersMiddleware() gin.HandlerFunc

Types

type AuthUser

type AuthUser struct {
	ID        uuid.UUID `json:"id"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	Role      string    `json:"role"`
	IsEnabled bool      `json:"isEnabled"`
	IsDeleted bool      `json:"isDeleted"`
	JTI       string    `json:"jti"`
}

func GetAuthUser

func GetAuthUser(ctx *gin.Context) (AuthUser, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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