jwt

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 11 Imported by: 1

README

JSON Web Token (JWT) Package

The official documentation of the jwt package will be here.

Documentation

Index

Constants

View Source
const (
	ParamTypeJWT               = "JWT"
	ParamPurposeAccess         = "access"
	ParamPurposeRefresh        = "refresh"
	ParamSigningAlgorithmHS256 = "HS256"
	ParamSigningAlgorithmHS512 = "HS512"
)

Variables

This section is empty.

Functions

func NewJwt

func NewJwt(
	config Config) *jwt

Types

type Config

type Config struct {
	SecretKey               string
	SigningAlgorithm        string
	Issuer                  string
	Subject                 string
	AccessTokenLifetimeSec  int
	RefreshTokenLifetimeSec int
}

type Jwt

type Jwt interface {
	Create(sessionID string, privateBox []byte, tokenPurpose string, issuedAt ...int64) (string, error)
	Validate(jwt string) (Token, error)
}

type MockDescription

type MockDescription struct {
	Props struct {
	}
	Expected struct {
		Error error
	}
}
var MockData MockDescription

func (*MockDescription) Create

func (s *MockDescription) Create(_ string, _ []byte, _ string, _ ...int64) (string, error)

func (*MockDescription) Validate

func (s *MockDescription) Validate(_ string) (Token, error)

type Token

type Token struct {
	Headers struct {
		SigningAlgorithm string `json:"alg"`
		Type             string `json:"typ"`
	}
	Payload struct {
		Issuer    string `json:"iss"`
		Subject   string `json:"sub"`
		Purpose   string `json:"purpose"`
		SessionID string `json:"sessionID"`
		Data      []byte `json:"data"`
		IssuedAt  int64  `json:"iat"`
	}
	Signature string
}

Jump to

Keyboard shortcuts

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