jwt

package
v0.0.0-...-b8330c8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDKey  = "user_id"
	ExamIDKey  = "exam_id"
	IsAdminKey = "is_admin"
)

Variables

This section is empty.

Functions

func GenerateRSAKey

func GenerateRSAKey(rsaPrivateKeyPath string, rsaPublicKeyPath string) (*rsa.PrivateKey, error)

func GetRSAKey

func GetRSAKey(logger *logrus.Logger, rsaPrivateKeyPath string, rsaPublicKeyPath string) (*rsa.PrivateKey, error)

Types

type Claims

type Claims struct {
	ID        string
	IssuedAt  time.Time
	ExpiredAt time.Time
	UserID    int32
	ExamID    int32
	IsAdmin   bool
}

type Service

type Service interface {
	GenerateAndSign(isAdmin bool, userID int32, examID int32) (string, error)
	VerifyAndDecode(token string) (Claims, error)
}

func NewService

func NewService(key *rsa.PrivateKey) (Service, error)

Jump to

Keyboard shortcuts

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