jwt

package
v0.0.0-...-3ccc3fb Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package jwt implements the JWT authentication

Index

Constants

View Source
const (
	Access  = "access"
	Refresh = "refresh"
)

Variables

View Source
var TokenTypeExpTime = map[string]string{
	Access:  "Secure.JWTAccessTimeMinute",
	Refresh: "Secure.JWTRefreshTimeHour",
}

TokenTypeExpTime is a map that contains the expiration time of the JWT

View Source
var TokenTypeKeyName = map[string]string{
	Access:  "Secure.JWTAccessSecure",
	Refresh: "Secure.JWTRefreshSecure",
}

TokenTypeKeyName is a map that contains the key name of the JWT in config.json

Functions

func GetClaimsAndVerifyToken

func GetClaimsAndVerifyToken(tokenString string, tokenType string) (claims jwt.MapClaims, err error)

GetClaimsAndVerifyToken verifies the token and returns the claims

Types

type AppToken

type AppToken struct {
	Token          string    `json:"token"`
	TokenType      string    `json:"type"`
	ExpirationTime time.Time `json:"expitationTime"`
}

AppToken is a struct that contains the JWT token

func GenerateJWTToken

func GenerateJWTToken(userID int, tokenType string) (appToken *AppToken, err error)

GenerateJWTToken generates a JWT token (refresh or access)

type Claims

type Claims struct {
	ID   int    `json:"id"`
	Type string `json:"type"`
	jwt.RegisteredClaims
}

Claims is a struct that contains the claims of the JWT

Jump to

Keyboard shortcuts

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