jwt

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const TokenCookieKey = "session_token"

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	jwt.RegisteredClaims
	UserID   string `json:"user_id"`
	UserName string `json:"user_name"`
}

type ClaimsContextKey

type ClaimsContextKey struct{}

type Service

type Service struct {
	SecretKey []byte
}

func (*Service) AuthMiddleware

func (s *Service) AuthMiddleware(next http.Handler) http.Handler

func (*Service) GenerateToken

func (s *Service) GenerateToken(userID string, userName string) (string, error)

func (*Service) GenerateTokenAndStore

func (s *Service) GenerateTokenAndStore(
	w http.ResponseWriter,
	userID string,
	userName string,
) error

func (*Service) VerifyToken

func (s *Service) VerifyToken(tokenString string) (*Claims, error)

Jump to

Keyboard shortcuts

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