keysd: Index | Files

package server

import ""


Package Files

access.go auth.go changes.go check.go disco.go error.go invite.go log.go memcache.go messages.go pubsub.go server.go sigchain.go tasks.go user.go

func ErrBadRequest Uses

func ErrBadRequest(c echo.Context, err error) error

ErrBadRequest response.

func ErrConflict Uses

func ErrConflict(c echo.Context, err error) error

ErrConflict response.

func ErrEntityTooLarge Uses

func ErrEntityTooLarge(c echo.Context, err error) error

ErrEntityTooLarge response.

func ErrForbidden Uses

func ErrForbidden(c echo.Context, err error) error

ErrForbidden response.

func ErrNotFound Uses

func ErrNotFound(c echo.Context, err error) error

ErrNotFound response.

func ErrResponse Uses

func ErrResponse(c echo.Context, status int, msg string) error

ErrResponse is a generate error response.

func ErrUnauthorized Uses

func ErrUnauthorized(c echo.Context, err error) error

ErrUnauthorized response.

func ErrorHandler Uses

func ErrorHandler(err error, c echo.Context)

ErrorHandler returns error handler that returns in the format: {"error": {"message": "error message", status: 500}}".

func JSON Uses

func JSON(c echo.Context, status int, i interface{}) error

JSON response.

func NewHandler Uses

func NewHandler(s *Server) http.Handler

NewHandler returns http.Handler for Server.

func NewPubSubHandler Uses

func NewPubSubHandler(s *PubSubServer) http.Handler

NewPubSubHandler returns http.Handler for Server.

type Access Uses

type Access struct {
    Allow   bool
    Message string
    // StatusCode (optional) for custom HTTP status (if denied)
    StatusCode int

Access returns whether to allow or deny.

func AccessAllow Uses

func AccessAllow() Access

AccessAllow allow access.

func AccessDeny Uses

func AccessDeny(msg string) Access

AccessDeny deny access (bad request).

func AccessDenyErrored Uses

func AccessDenyErrored(err error) Access

AccessDenyErrored deny access (an error occurred trying to determine access).

func AccessDenyTooManyRequests Uses

func AccessDenyTooManyRequests(msg string) Access

AccessDenyTooManyRequests deny access (too many requests).

type AccessAction Uses

type AccessAction string

AccessAction is action for access control.

const (
    // Put action.
    Put AccessAction = "put"
    // Post action.
    Post AccessAction = "post"

type AccessContext Uses

type AccessContext interface {
    RealIP() string
    Request() *http.Request

AccessContext is context for request.

type AccessFn Uses

type AccessFn func(c AccessContext, resource AccessResource, action AccessAction) Access

AccessFn returns access to resource. If error message begins with an integer, it will use that as the http status code. For example, "429: too many requests".

type AccessResource Uses

type AccessResource string

AccessResource is resource for access control.

const (
    // SigchainResource for sigchain.
    SigchainResource AccessResource = "sigchain"

func (AccessResource) String Uses

func (r AccessResource) String() string

type Fire Uses

type Fire interface {

Fire defines interface for remote store (like Firestore).

type LogLevel Uses

type LogLevel int

LogLevel ...

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

type Logger Uses

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

Logger compatible with GCP.

func NewLogger Uses

func NewLogger(lev LogLevel) Logger

NewLogger ...

type MemCache Uses

type MemCache interface {
    // Get returns value at key.
    Get(ctx context.Context, k string) (string, error)
    // Put puts a value at key.
    Set(ctx context.Context, k string, v string) error
    // Delete key.
    Delete(ctx context.Context, k string) error
    // Expire key.
    Expire(ctx context.Context, k string, dt time.Duration) error
    // Increment value at key.
    Increment(ctx context.Context, k string) (int64, error)

MemCache defines interface for memcache. Used to prevent nonce re-use for authenticated requests.

func NewMemTestCache Uses

func NewMemTestCache(nowFn func() time.Time) MemCache

NewMemTestCache returns in memory MemCache (for testing).

type PubSub Uses

type PubSub interface {
    Publish(ctx context.Context, name string, b []byte) error
    Subscribe(ctx context.Context, name string, receiveFn func(b []byte)) error

func NewPubSub Uses

func NewPubSub() PubSub

NewPubSub is PubSub for testing.

type PubSubServer Uses

type PubSubServer struct {
    URL string
    // contains filtered or unexported fields

func NewPubSubServer Uses

func NewPubSubServer(pubSub PubSub, mc MemCache, logger Logger) *PubSubServer

func (*PubSubServer) AddRoutes Uses

func (s *PubSubServer) AddRoutes(e *echo.Echo)

AddRoutes adds routes to an Echo instance.

func (*PubSubServer) SetNowFn Uses

func (s *PubSubServer) SetNowFn(nowFn func() time.Time)

SetNowFn sets clock Now function.

type Server Uses

type Server struct {

    // URL (base) of form http(s)://host:port with no trailing slash to help
    // authorization checks in testing where the host is ambiguous.
    URL string
    // contains filtered or unexported fields

Server ...

func NewServer Uses

func NewServer(fi Fire, mc MemCache, users *keys.UserStore, logger Logger) *Server

NewServer creates a Server.

func (*Server) AddRoutes Uses

func (s *Server) AddRoutes(e *echo.Echo)

AddRoutes adds routes to an Echo instance.

func (*Server) SetAccessFn Uses

func (s *Server) SetAccessFn(fn AccessFn)

SetAccessFn sets access control.

func (*Server) SetInternalAuth Uses

func (s *Server) SetInternalAuth(internalAuth string)

SetInternalAuth for authorizing internal requests, like tasks.

func (*Server) SetNowFn Uses

func (s *Server) SetNowFn(nowFn func() time.Time)

SetNowFn sets clock Now function.

func (*Server) SetTasks Uses

func (s *Server) SetTasks(tasks Tasks)

SetTasks ...

type Tasks Uses

type Tasks interface {
    // CreateTask ...
    CreateTask(ctx context.Context, method string, url string, authToken string) error

Tasks ..

func NewTestTasks Uses

func NewTestTasks(svr *Server) Tasks

NewTestTasks returns Tasks for use in tests.

Package server imports 17 packages (graph). Updated 2020-04-09. Refresh now. Tools for package owners.