util

package
v0.0.0-...-e6cac86 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 29 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Signer jose.Signer
	Keys   *jose.JSONWebKeySet
)

Functions

func CompactHash

func CompactHash(data []byte) string

func CompactUUID

func CompactUUID() string

func ConnectDb

func ConnectDb() (*gorm.DB, error)

func Contains

func Contains(container, things []string) bool

func DecodeJWTClose

func DecodeJWTClose(raw, passphrase string, decoded interface{}) error

func DecodeJWTOpen

func DecodeJWTOpen(raw string, decoded interface{}) error

func DecodeJWTOpenFromKeys

func DecodeJWTOpenFromKeys(raw string, keys *jose.JSONWebKeySet, decoded interface{}) error

func Decrypt

func Decrypt(passphrase string, ciphertext []byte) ([]byte, error)

func DeriveKey

func DeriveKey(passphrase string) []byte

func EncodeJWTClose

func EncodeJWTClose(tok interface{}, passphrase string) (string, error)

func EncodeJWTOpen

func EncodeJWTOpen(tok interface{}) (string, error)

func Encrypt

func Encrypt(passphrase string, plaintext []byte) ([]byte, error)

func GetDb

func GetDb() *gorm.DB

func IndexOf

func IndexOf(it string, list []string) (int, bool)

func LoadKey

func LoadKey(keyFile string) error

func PasswordHash

func PasswordHash(plaintext []byte) ([]byte, error)

func PasswordHashValid

func PasswordHashValid(plaintext, hash []byte) bool

func RenderEmailTemplate

func RenderEmailTemplate(template string, context map[string]interface{}) (subjectOutput, plainOutput, htmlOutput []byte, renderErr error)

func RenderHTMLTemplate

func RenderHTMLTemplate(template string, context map[string]interface{}) (output []byte, renderErr error)

func RenderTemplate

func RenderTemplate(style, template string, context map[string]interface{}) (output []byte, renderErr error)

func Reverse

func Reverse(input *[]string)

func SendMail

func SendMail(name, address, template string, context TemplateContext) error

func SetDb

func SetDb(newDb *gorm.DB)

func TrunkUrlFragment

func TrunkUrlFragment(domList []string) string

Types

type Cacher

type Cacher struct {
	// contains filtered or unexported fields
}

func NewCacher

func NewCacher(ttl time.Duration, generator func() (interface{}, error)) *Cacher

func (*Cacher) Fetch

func (self *Cacher) Fetch() (interface{}, error)

type IdpVerifierCache

type IdpVerifierCache struct {
	// contains filtered or unexported fields
}

func NewIdpVerifierCache

func NewIdpVerifierCache() (newCacher *IdpVerifierCache)

func (*IdpVerifierCache) Fetch

func (verifier *IdpVerifierCache) Fetch() (*jose.JSONWebKeySet, *RevMap, error)

type RevMap

type RevMap struct {
	// contains filtered or unexported fields
}

func NewRevMap

func NewRevMap() *RevMap

func (*RevMap) Add

func (rev *RevMap) Add(field, key string, created, duration int)

func (*RevMap) Revoked

func (rev *RevMap) Revoked(field, key string, issued int) bool

type TemplateContext

type TemplateContext map[string]interface{}

type VerifierCache

type VerifierCache interface {
	Fetch() (*jose.JSONWebKeySet, *RevMap, error)
}

Jump to

Keyboard shortcuts

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