jwt

package
v0.0.0-...-1a5deed Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCodeInvalidExpiryDate is the error code when claims[keyExp] is invalid
	ErrCodeInvalidExpiryDate = stacktrace.ErrorCode(1)
)
View Source
var (
	// ErrTokenBlacklisted is thrown when a jwt token is blacklisted
	ErrTokenBlacklisted = errors.New("token has been blacklisted")
)

Functions

This section is empty.

Types

type Service

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

Service is a new instance of the JWT service

func NewService

func NewService(secret string, cache cache.Cache, sessionDays int) Service

NewService creates a new instance of the JWT service

func (Service) GenerateTokenForUserID

func (service Service) GenerateTokenForUserID(UserID id.ID) (result string, err error)

GenerateTokenForUserID generates a jwt token and assign a email to it's claims and return it

func (Service) GetUserIDFromToken

func (service Service) GetUserIDFromToken(tokenString string) (userID id.ID, err error)

GetUserIDFromToken parses a jwt token and returns the user ID

func (Service) InvalidateToken

func (service Service) InvalidateToken(tokenString string) (err error)

InvalidateToken invalidates a jwt token

func (Service) IsValid

func (service Service) IsValid(tokenString string) bool

IsValid checks if a token is valid

Jump to

Keyboard shortcuts

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