middleware

package
v0.0.0-...-87c02f1 Latest Latest
Warning

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

Go to latest
Published: May 7, 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 AuthService

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

func NewAuthService

func NewAuthService(opts *AuthServiceOpts) *AuthService

func (*AuthService) ValidateToken

func (s *AuthService) ValidateToken(ctx context.Context) (*UserClaims, error)

type AuthServiceOpts

type AuthServiceOpts struct {
	TokenHandler *TokenHandler
}

type GlobalServiceKey

type GlobalServiceKey string

type TokenHandler

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

func NewTokenHandler

func NewTokenHandler(opts TokenHandlerOpts) *TokenHandler

func (*TokenHandler) CreateToken

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

func (*TokenHandler) ParseToken

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

type TokenHandlerOpts

type TokenHandlerOpts struct {
	JwtConfig *config.Jwt
}

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