tokens

package
v0.0.0-...-226ad4c Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: AGPL-3.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCookie

func CreateCookie(data interface{}, hostName string, cookieName string, duration time.Duration, w http.ResponseWriter)

CreateCookie creates a token with the given data and returns it in a cookie

func CreateToken

func CreateToken(data interface{}, expiration time.Time) (string, error)

CreateToken creates a token with the given data

func Decrypt

func Decrypt(data []byte, key []byte) ([]byte, error)

Decrypt a byte array with AES

func Encrypt

func Encrypt(data []byte, key []byte) ([]byte, error)

Encrypt a byte array with AES

func ExtractAndValidateToken

func ExtractAndValidateToken(r *http.Request, cookieName string, v interface{}, checkXSRF bool) (bool, error)

ExtractAndValidateToken extracts the token from the request, validates it, and return the data n the value pointed to by v

func Init

func Init(keyfile string, debug bool)

Init inits the main token manager

func InitFromString

func InitFromString(key string, debug bool)

InitFromString inits the main token manager from a given string

Types

type Token

type Token struct {
	ExpiresAt int64
	IssuedAt  int64 `json:"iat,omitempty"`
	Data      []byte
}

Token represents a token containting data

Jump to

Keyboard shortcuts

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