token

package
v0.0.0-...-55c0a6c Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TOKEN_JWT       = "JWT"
	TOKEN_FVT       = "FVT"
	ALGORITHM_HS256 = "HS256"
	ALGORITHM_HS384 = "HS384"
	ALGORITHM_HS512 = "HS512"
)
View Source
const TOKENLIVETIME = 960

Variables

This section is empty.

Functions

func VerifyToken

func VerifyToken(tokenstring string, key []byte) (bool, error)

Types

type FVT

type FVT struct {
	Token
	Header  *TokenHeader
	Payload TPayLoadInterface
}

func (*FVT) GetHeader

func (t *FVT) GetHeader() *TokenHeader

func (*FVT) GetPayLoad

func (t *FVT) GetPayLoad() TPayLoadInterface

func (*FVT) LoadHeader

func (t *FVT) LoadHeader(header *TokenHeader)

func (*FVT) LoadPayLoad

func (t *FVT) LoadPayLoad(b64 string) error

func (*FVT) SetPayLoad

func (t *FVT) SetPayLoad(p TPayLoadInterface) error

func (*FVT) String

func (t *FVT) String(k []byte) (token string, err error)

func (*FVT) Verify

func (t *FVT) Verify(tokenString string, key []byte) (check bool, err error)

type FVTPayLoad

type FVTPayLoad struct {
	ClientId       string `json:"rqi"`
	State          string `json:"stt"`
	ExpirationTime int    `json:"exp"`
	NotBefore      int    `json:"nbf"`
	IssuedAt       int    `json:"iat"`
	CSRFToken      string `json:"cft"`
	TPayLoadInterface
}

func NewFvtTokenData

func NewFvtTokenData(req string, state string, CSRFToken string, issuedAt int) *FVTPayLoad

func (*FVTPayLoad) ToJson

func (p *FVTPayLoad) ToJson() (bytes []byte, err error)

JSWTPayload

type JWT

type JWT struct {
	Token
	Header  *TokenHeader
	Payload TPayLoadInterface
	// contains filtered or unexported fields
}

func (*JWT) GetHeader

func (t *JWT) GetHeader() *TokenHeader

func (*JWT) GetPayLoad

func (t *JWT) GetPayLoad() TPayLoadInterface

func (*JWT) LoadHeader

func (t *JWT) LoadHeader(header *TokenHeader)

func (*JWT) LoadPayLoad

func (t *JWT) LoadPayLoad(b64 string) error

func (*JWT) SetPayLoad

func (t *JWT) SetPayLoad(p TPayLoadInterface) error

func (*JWT) String

func (t *JWT) String(k []byte) (token string, err error)

func (*JWT) Verify

func (t *JWT) Verify(tokenString string, key []byte) (check bool, err error)

type JWTPayLoad

type JWTPayLoad struct {
	Issuer         string `json:"iss"`
	Subject        string `json:"sub"`
	Audience       string `json:"aud"`
	ExpirationTime int    `json:"exp"`
	NotBefore      int    `json:"nbf"`
	IssuedAt       int    `json:"iat"`
	JWTId          string `json:"jti"`
	TPayLoadInterface
}

func (*JWTPayLoad) ToJson

func (p *JWTPayLoad) ToJson() (bytes []byte, err error)

JSWTPayload

type THeaderInterface

type THeaderInterface interface {
	ToJson() ([]byte, error)
	GetAlgorithm() hash.Hash
}

type TPayLoadInterface

type TPayLoadInterface interface {
	ToJson() ([]byte, error)
}

type Token

type Token interface {
	GetHeader() *TokenHeader
	GetPayLoad() TPayLoadInterface
	String(key []byte) (string, error)
	Verify(token string, key []byte) (bool, error)
	SetPayLoad(p TPayLoadInterface) error
	LoadPayLoad(b64 string) error
	LoadHeader(header *TokenHeader)
}

func LoadToken

func LoadToken(t string) (Token, error)

func NewToken

func NewToken(typ string) Token

type TokenHeader

type TokenHeader struct {
	Algorithm string `json:"alg"`
	TokenType string `json:"typ"`
	THeaderInterface
}

func (*TokenHeader) GetAlgorithm

func (h *TokenHeader) GetAlgorithm() hash.Hash

func (*TokenHeader) ToJson

func (h *TokenHeader) ToJson() (bytes []byte, err error)

TokenHeader

Jump to

Keyboard shortcuts

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