user

package module
v0.0.0-...-c031696 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const End = "END KEYUP MESSAGE."

End of a signed message

View Source
const Start = "BEGIN KEYUP MESSAGE."

Start of a signed message

Variables

View Source
var ErrUserAlreadySet = errors.New("user set in sigchain already")

ErrUserAlreadySet is user already set in sigchain.

Functions

func CheckUser

func CheckUser(ctx context.Context, usr *User, spk keyup.SignPublicKey, req Requestor) error

CheckUser verified the user statement URL.

func FindMessage

func FindMessage(body string) (string, error)

FindMessage finds a message in HTML data

func GenerateStatement

func GenerateStatement(sc *keyup.Sigchain, usr *User, sk *keyup.SignKey) (*keyup.Statement, error)

GenerateStatement for a user to add to the sigchain.

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

func Sign

func Sign(key keyup.Key, usr *User) (string, error)

Sign usr into an armored message.

func Trim

func Trim(msg string) (string, error)

Trim signed message content.

func ValidateStatement

func ValidateStatement(st *keyup.Statement) error

ValidateStatement returns error if statement is not a valid user statement.

Types

type Cache

type Cache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Cache user information.

func NewCache

func NewCache(dst keyup.Datastore, scs keyup.SigchainStore) *Cache

NewCache creates a Cache.

func (*Cache) Expired

func (c *Cache) Expired(ctx context.Context, dt time.Duration) ([]keyup.ID, error)

Expired returns KIDs that haven't been checked in a duration.

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, kid keyup.ID) ([]*User, error)

Get users for KID.

func (*Cache) Search

func (c *Cache) Search(ctx context.Context, req *SearchRequest) (*SearchResult, error)

Search for users.

func (*Cache) SetNowFn

func (c *Cache) SetNowFn(nowFn func() time.Time)

SetNowFn sets time.Now function.

func (*Cache) SetRequestor

func (c *Cache) SetRequestor(req Requestor)

SetRequestor sets the request implementation. For example, on google cloud this would use urlfetch.

func (*Cache) Update

func (c *Cache) Update(ctx context.Context, kid keyup.ID) error

Update user cache for sigchain.

type ContextLogger

type ContextLogger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warningf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}

ContextLogger interface used in this package with request context.

func NewContextLogger

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

type ErrHTTP

type ErrHTTP struct {
	StatusCode int
}

ErrHTTP is an HTTP Error

func (ErrHTTP) Error

func (e ErrHTTP) Error() string

type ErrTemporary

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

ErrTemporary means there was a temporary error

func NewErrTemporary

func NewErrTemporary(msg string) ErrTemporary

NewErrTemporary creates temporary error

func (ErrTemporary) Error

func (e ErrTemporary) Error() string

func (ErrTemporary) Temporary

func (e ErrTemporary) Temporary() bool

Temporary returns true

type ErrTimeout

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

ErrTimeout is a timeout error

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Requestor

type Requestor interface {
	RequestURL(ctx context.Context, u *url.URL) ([]byte, error)
}

Requestor ...

func NewHTTPRequestor

func NewHTTPRequestor() Requestor

NewHTTPRequestor ...

type SearchRequest

type SearchRequest struct {
	Query string
	Index int
	Limit int
	KIDs  bool
}

SearchRequest ...

type SearchResult

type SearchResult struct {
	Users []*User
	KIDs  []keyup.ID
}

SearchResult ...

type User

type User struct {
	Name      string
	KID       keyup.ID
	Seq       int
	Service   string
	URL       string
	CheckedAt time.Time
}

User is a statement about a user on a service with a signed statement at a URL.

func Check

func Check(ctx context.Context, sc *keyup.Sigchain, req Requestor, nowFn func() time.Time) ([]*User, error)

Check returns verified user statements URL in sigchain.

func FindInSigchain

func FindInSigchain(sc *keyup.Sigchain) ([]*User, error)

FindInSigchain user statements in the sigchain.

func NewUser

func NewUser(kid keyup.ID, service string, name string, rawurl string, seq int) (*User, error)

NewUser returns User used in a signing statement.

func NewUserForSigning

func NewUserForSigning(kid keyup.ID, service string, name string) (*User, error)

NewUserForSigning returns User for signing (doesn't have remote URL yet).

func Verify

func Verify(msg string, spk keyup.SignPublicKey, usr *User) (*User, error)

Verify armored message for a user. If usr is specified, we will verify it matches the User in the verified message.

func (User) Bytes

func (u User) Bytes() []byte

Bytes is a serialized User.

func (User) MarshalJSON

func (u User) MarshalJSON() ([]byte, error)

MarshalJSON marshals user to JSON.

func (User) String

func (u User) String() string

func (*User) UnmarshalJSON

func (u *User) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals a user from JSON.

Jump to

Keyboard shortcuts

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