mid

package
v0.0.0-...-3455009 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package mid provides app level middleware support.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidID = errors.New("ID is not in its proper form")

ErrInvalidID represents a condition where the id is not a uuid.

Functions

func Authenticate

func Authenticate(log *logger.Logger, client *authclient.Client) gin.HandlerFunc

Authenticate 通过 auth 服务验证身份验证

func AuthenticateLocal

func AuthenticateLocal(auth *auth.Auth) gin.HandlerFunc

AuthenticateLocal validates a JWT from the `Authorization` header. AuthenticateLocal 通过 “Authorization” 标头验证 JWT。 AuthenticateLocal 本地处理验证

func Authorize

func Authorize(log *logger.Logger, client *authclient.Client, rule string) gin.HandlerFunc

Authorize executes the specified role and does not extract any domain data.

func AuthorizeUser

func AuthorizeUser(log *logger.Logger, client *authclient.Client, userBus *userbus.Business, rule string) gin.HandlerFunc

AuthorizeUser executes the specified role and extracts the specified user from the DB if a user id is specified in the call. Depending on the rule specified, the userid from the claims may be compared with the specified user id.

func Basic

func Basic() gin.HandlerFunc

Basic processes basic authentication logic.

func Bearer

func Bearer(ath *auth.Auth) gin.HandlerFunc

Bearer processes JWT authentication logic.

func CheckError

func CheckError() gin.HandlerFunc

func Errors

func Errors(log *logger.Logger) gin.HandlerFunc

func GetClaims

func GetClaims(ctx context.Context) auth.Claims

GetClaims returns the claims from the context.

func GetUser

func GetUser(ctx context.Context) (userbus.User, error)

GetUser returns the user from the context.

func GetUserID

func GetUserID(ctx context.Context) (uuid.UUID, error)

GetUserID returns the claims from the context.

func Logger

func Logger(log *logger.Logger) gin.HandlerFunc

func Metrics

func Metrics() gin.HandlerFunc

func Panics

func Panics() gin.HandlerFunc

func Trace

func Trace() gin.HandlerFunc

Types

type Handler

type Handler func(context.Context) error

Handler represents the handler function that needs to be called.

Jump to

Keyboard shortcuts

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