Versions in this module Expand all Collapse all v2 v2.0.0 Feb 6, 2022 Changes in this version + var ErrInvalidTokenPIN = errors.New("invalid PIN in token") + var ErrInvalidTokenUID = errors.New("invalid UID in token") + var ErrNoResponseWriter = errors.New(...) + var ErrNoStore = errors.New("no store has been configured") + var ErrNoTransport = errors.New("no transports have been configured") + var ErrNotValidForContext = errors.New("strategy not valid for context") + var ErrTokenNotFound = errors.New("the token does not exist") + var ErrTokenNotValid = errors.New("the token is incorrect") + var ErrUnknownStrategy = errors.New("unknown strategy") + var ErrWrongTokenUID = errors.New("wrong UID in token") + func RequestToken(ctx context.Context, s TokenStore, t Strategy, uid, recipient string) error + func SetContext(ctx context.Context, rw http.ResponseWriter, r *http.Request) context.Context + func VerifyToken(ctx context.Context, s TokenStore, uid, token string) (bool, error) + type ByteGenerator struct + Bytes []byte + Length int + func NewByteGenerator(b []byte, l int) *ByteGenerator + func (g ByteGenerator) Generate(ctx context.Context) (string, error) + func (g ByteGenerator) Sanitize(ctx context.Context, s string) (string, error) + type ComposerFunc func(ctx context.Context, token, user, recipient string, w io.Writer) error + type CookieStore struct + Key string + Path string + func NewCookieStore(signingKey, authKey, encrKey []byte) *CookieStore + func (s *CookieStore) Delete(ctx context.Context, uid string) error + func (s *CookieStore) Exists(ctx context.Context, uid string) (bool, time.Time, error) + func (s *CookieStore) Store(ctx context.Context, token, uid string, ttl time.Duration) error + func (s *CookieStore) Verify(ctx context.Context, pin, uid string) (bool, error) + type CrockfordGenerator struct + Length int + func NewCrockfordGenerator(l int) *CrockfordGenerator + func (g CrockfordGenerator) Generate(ctx context.Context) (string, error) + func (g CrockfordGenerator) Sanitize(ctx context.Context, s string) (string, error) + type Email struct + Body []struct{} + Date time.Time + Subject string + To string + func (e *Email) AddBody(contentType, body string) + func (e Email) Buffer() *bytes.Buffer + func (e Email) Bytes() []byte + func (e Email) Write(w io.Writer) (int64, error) + type LogTransport struct + MessageFunc func(token, uid string) string + func (lt LogTransport) Send(ctx context.Context, token, user, recipient string) error + type MemStore struct + func NewMemStore() *MemStore + func (s *MemStore) Clean() + func (s *MemStore) Delete(ctx context.Context, uid string) error + func (s *MemStore) Exists(ctx context.Context, uid string) (bool, time.Time, error) + func (s *MemStore) Release() + func (s *MemStore) Store(ctx context.Context, token, uid string, ttl time.Duration) error + func (s *MemStore) Verify(ctx context.Context, token, uid string) (bool, error) + type PINGenerator struct + Length int + func (g PINGenerator) Generate(ctx context.Context) (string, error) + func (g PINGenerator) Sanitize(ctx context.Context, s string) (string, error) + type Passwordless struct + Store TokenStore + Strategies map[string]Strategy + func New(store TokenStore) *Passwordless + func (p *Passwordless) GetStrategy(ctx context.Context, name string) (Strategy, error) + func (p *Passwordless) ListStrategies(ctx context.Context) map[string]Strategy + func (p *Passwordless) RequestToken(ctx context.Context, s, uid, recipient string) error + func (p *Passwordless) SetStrategy(name string, s Strategy) + func (p *Passwordless) SetTransport(name string, t Transport, g TokenGenerator, ttl time.Duration) Strategy + func (p *Passwordless) VerifyToken(ctx context.Context, uid, token string) (bool, error) + type RedisStore struct + func NewRedisStore(client redis.UniversalClient) *RedisStore + func (s RedisStore) Delete(ctx context.Context, uid string) error + func (s RedisStore) Exists(ctx context.Context, uid string) (bool, time.Time, error) + func (s RedisStore) Store(ctx context.Context, token, uid string, ttl time.Duration) error + func (s RedisStore) Verify(ctx context.Context, token, uid string) (bool, error) + type SMTPTransport struct + UseSSL bool + func NewSMTPTransport(addr, from string, auth smtp.Auth, c ComposerFunc) *SMTPTransport + func (t *SMTPTransport) Send(ctx context.Context, token, uid, recipient string) error + type SimpleStrategy struct + func (s SimpleStrategy) TTL(context.Context) time.Duration + func (s SimpleStrategy) Valid(context.Context) bool + type Strategy interface + TTL func(context.Context) time.Duration + Valid func(context.Context) bool + type TokenGenerator interface + Generate func(ctx context.Context) (string, error) + Sanitize func(ctx context.Context, s string) (string, error) + type TokenStore interface + Delete func(ctx context.Context, uid string) error + Exists func(ctx context.Context, uid string) (bool, time.Time, error) + Store func(ctx context.Context, token, uid string, ttl time.Duration) error + Verify func(ctx context.Context, token, uid string) (bool, error) + type Transport interface + Send func(ctx context.Context, token, user, recipient string) error Other modules containing this package github.com/johnsto/go-passwordless