middleware

package
v0.0.0-...-c61f402 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AuthServiceKey        = GlobalServiceKey("authService")
	GrpcMethodsServiceKey = GlobalServiceKey("grpcMethodsService")
)

Functions

func AuthorizationServerInterceptor

func AuthorizationServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func GetGlobalService

func GetGlobalService(k GlobalServiceKey) interface{}

func LoggingServerInterceptor

func LoggingServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func RegisterGlobalService

func RegisterGlobalService(ctx context.Context, service interface{}) context.Context

Types

type GlobalServiceKey

type GlobalServiceKey string

type GrpcMethod

type GrpcMethod struct {
	Name string
}

type GrpcMethodService

type GrpcMethodService struct {
	// contains filtered or unexported fields
}

func NewGrpMethodsService

func NewGrpMethodsService() *GrpcMethodService

func (*GrpcMethodService) IsPublicMethod

func (s *GrpcMethodService) IsPublicMethod(method string) bool

type TokenMiddleware

type TokenMiddleware struct {
	Conf *config.Config
}

func NewTokenMiddleware

func NewTokenMiddleware(
	conf *config.Config,
) *TokenMiddleware

func (*TokenMiddleware) CreateToken

func (t *TokenMiddleware) CreateToken(user *model.User) (string, error)

func (*TokenMiddleware) ParseToken

func (t *TokenMiddleware) ParseToken(tokenString string) (*UserClaims, error)

func (*TokenMiddleware) ValidateToken

func (t *TokenMiddleware) ValidateToken(ctx context.Context) (*UserClaims, error)

type UserClaims

type UserClaims struct {
	*jwt.StandardClaims
	UserInfo
}

type UserInfo

type UserInfo struct {
	Username string `json:"username"`
	Id       int    `json:"id"`
}

Jump to

Keyboard shortcuts

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