jwt

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRefreshTokenLifeSpanHours time.Duration = 24 * time.Hour //24 hours

DefaultRefreshTokenLifeSpanHours is the default ttl for jwt refresh token

View Source
var DefaultTokenLifeSpan time.Duration = 15 * time.Minute //15 minutes

DefaultTokenLifeSpan is the default ttl for jwt token

View Source
var USER_ID = "userID"

Functions

func RefreshToken

func RefreshToken(token string, refreshToken string) (newToken string, err error)

RefreshToken generates a new token based on the refresh token TODO: implement

Types

type JWTUtil

type JWTUtil struct{}

JWTUtil pakcage struct

var JWT *JWTUtil

func New

func New() *JWTUtil

New initiates Jwt struct

func Resolve

func Resolve() *JWTUtil

Resolve returns initiated jwt token

func (*JWTUtil) CreateRefreshToken

func (j *JWTUtil) CreateRefreshToken(userID uint) (string, error)

CreateRefreshToken generates new jwt refresh token with the given user id

func (*JWTUtil) CreateToken

func (j *JWTUtil) CreateToken(userID uint) (string, error)

CreateToken generates new jwt token with the given user id

func (*JWTUtil) DecodeToken

func (j *JWTUtil) DecodeToken(tokenString string) (userID uint, err error)

DecodeToken decodes a given token and returns the user id

func (*JWTUtil) ExtractToken

func (j *JWTUtil) ExtractToken(c *gin.Context) (token string, err error)

ExtractToken extracts the token from the request header

func (*JWTUtil) ValidateToken

func (j *JWTUtil) ValidateToken(tokenString string) (bool, error)

ValidateToken makes sure the given token is valid

Jump to

Keyboard shortcuts

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