jwttoken

package
v0.0.0-...-fb01ae8 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(user string) (string, error)

func DeleteToken

func DeleteToken(c *gin.Context)

Delete the token from the header

func GetToken

func GetToken(c *gin.Context) (string, error)

Get the token from the header

func GetUserFromToken

func GetUserFromToken(c *gin.Context) (string, error)

func IsLoggedIn

func IsLoggedIn(c *gin.Context) bool

func JwtMiddleware

func JwtMiddleware() gin.HandlerFunc

func ParseToken

func ParseToken(token string, secret string) (*jwt.Token, error)

Parse the token

func RefreshToken

func RefreshToken(c *gin.Context)

refresh token

func SetToken

func SetToken(c *gin.Context, token string)

Set the token in the header

Types

type UserToken

type UserToken struct {
	UserID    string `json:"user_id"`
	Username  string `json:"username"`
	Role      string `json:"role"`
	Issuer    string `json:"iss"`
	IssuedAt  int64  `json:"iat"`
	ExpiresAt int64  `json:"exp"`
	RefreshAt int64  `json:"ref"`
}

Jump to

Keyboard shortcuts

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