jwt

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package jwt provides functions for JWT token manipulation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken(signingKey string, timeZone string, timeoutPeriod string, issuer string, subject string, audience string, data string) (string, string, int64, error)

Generate token generates a JWT token and returns the encoded token data, token SHA256, and expiration time (in the respective order)

func GetAudience

func GetAudience(tokenString string) (string, error)

Get the audience of the token

func GetExpirationTime

func GetExpirationTime(tokenString string) (int64, error)

Get the expiration time of the token

func ValidateToken

func ValidateToken(targetTokenString, sourceTokenString, tokenSHA256, signingKey string) (bool, error)

Validate token uses a JWT token string and a signing key to validate the token

Types

type JWTToken

type JWTToken struct {
	Header struct {
		Algorithm string `json:"algorithm"`
		Type      string `json:"type"`
	} `json:"header"`
	Payload struct {
		ExpirationTime int64  `json:"expirationTime"`
		IssuedAt       int64  `json:"issuedAt"`
		Issuer         string `json:"issuer"`
		Subject        string `json:"subject"`
		Audience       string `json:"audience"`
		JwtID          string `json:"jwtID"`
		Data           string `json:"data"`
	} `json:"payload"`
	Signature string `json:"signature"`
}

JWTToken struct for JWT token

Jump to

Keyboard shortcuts

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