itokens

package
v1.202405300917.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPayload  = errors.New("invalid payload")
	ErrSignerError     = errors.New("signer error")
	ErrTokenExpired    = errors.New("token expired")
	ErrInvalidToken    = errors.New("invalid token")
	ErrInvalidAudience = errors.New("invalid token audience")
)

Functions

This section is empty.

Types

type ITokens

type ITokens interface {

	// Payload must be sent by reference
	// All payload fields go to token payload
	// Audience = payload.Type.package + payload.Type.Name
	IssueToken(app istructs.AppQName, duration time.Duration, pointerToPayload interface{}) (token string, err error)

	// Payload must be sent by reference
	// payload MUST be a pointer to the struct of the type used in IssueToken (checked using Audience)
	// Token is verified and its data is copied to *pointerToPayload
	// ErrTokenExpired, ErrInvalidToken, ErrInvalidAudience might be returned
	ValidateToken(token string, pointerToPayload interface{}) (gp istructs.GenericPayload, err error)

	// CryptoHash256 must be a cryptographic hash function which produces a 256-bits hash
	// Ref. https://en.wikipedia.org/wiki/Cryptographic_hash_function
	// Ref. https://pkg.go.dev/crypto/sha256
	CryptoHash256(data []byte) (hash [32]byte)
}

Jump to

Keyboard shortcuts

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