token

package
v0.0.0-...-a6aec48 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTManager

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

JWTManager provides our expires time and the secret key to create the tokens

func NewJWTManager

func NewJWTManager(secretKey string, tokenDuration time.Duration) *JWTManager

NewJWTManager returns a JWTManager

func (*JWTManager) GenerateToken

func (manager *JWTManager) GenerateToken(user *UserToken) (string, error)

Generate generates and signs a new token for a user

func (*JWTManager) VerifyToken

func (manager *JWTManager) VerifyToken(accessToken string) (*UserClaims, error)

VerifyToken will return a UserClaims struct or an error

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	UserID   string `json:"_id"`
	Username string `json:"username"`
	Role     string `json:"role"`
}

UserClaims privide username

type UserToken

type UserToken struct {
	UserID   string
	Username string
	Role     string
}

UserToken represents the token

Jump to

Keyboard shortcuts

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