server

package
v0.0.0-...-4452015 Latest Latest
Warning

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

Go to latest
Published: May 18, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPErrMap = map[int]*httpErrResp{
	knox.NoKeyIDCode:                   &httpErrResp{http.StatusBadRequest, "Missing Key ID"},
	knox.InternalServerErrorCode:       &httpErrResp{http.StatusInternalServerError, "Internal Server Error"},
	knox.KeyIdentifierExistsCode:       &httpErrResp{http.StatusBadRequest, "Key identifer exists"},
	knox.KeyVersionDoesNotExistCode:    &httpErrResp{http.StatusNotFound, "Key version does not exist"},
	knox.KeyIdentifierDoesNotExistCode: &httpErrResp{http.StatusNotFound, "Key identifer does not exist"},
	knox.UnauthenticatedCode:           &httpErrResp{http.StatusUnauthorized, "User or machine is not authenticated"},
	knox.UnauthorizedCode:              &httpErrResp{http.StatusForbidden, "User or machine not authorized"},
	knox.NotYetImplementedCode:         &httpErrResp{http.StatusNotImplemented, "Not yet implemented"},
	knox.NotFoundCode:                  &httpErrResp{http.StatusNotFound, "Route not found"},
	knox.NoKeyDataCode:                 &httpErrResp{http.StatusBadRequest, "Missing Key Data"},
	knox.BadRequestDataCode:            &httpErrResp{http.StatusBadRequest, "Bad request format"},
}

HTTPErrMap is a mapping from err subcodes to the http err response that will be returned.

Functions

func AddDefaultAccess

func AddDefaultAccess(a *knox.Access)

AddDefaultAccess adds an access to every created key.

func AddHeader

func AddHeader(k, v string) func(http.HandlerFunc) http.HandlerFunc

AddHeader adds a HTTP header to the response

func Authentication

func Authentication(providers []auth.Provider) func(http.HandlerFunc) http.HandlerFunc

Authentication sets the principal or returns an error if the principal cannot be authenticated.

func GetAPIError

func GetAPIError(r *http.Request) *httpError

GetAPIError gets the HTTP error that will be returned from the server.

func GetPrincipal

func GetPrincipal(r *http.Request) knox.Principal

GetPrincipal gets the principal authenticated through the authentication decorator

func GetRouteID

func GetRouteID(r *http.Request) string

GetRouteID gets the short form function name for the route being called. Used for logging/metrics.

func GetRouter

func GetRouter(cryptor keydb.Cryptor, db keydb.DB, decorators [](func(http.HandlerFunc) http.HandlerFunc)) *mux.Router

GetRouter creates the mux router that serves knox routes. All routes are declared in this file. Each handler itself takes in the db and auth provider interfaces and returns a handler that the is processed through the API Middleware.

func Logger

func Logger(logger *log.Logger) func(http.HandlerFunc) http.HandlerFunc

Logger logs the request and response information in json format to the logger given.

Types

type KeyManager

type KeyManager interface {
	GetAllKeyIDs() ([]string, error)
	GetUpdatedKeyIDs(map[string]string) ([]string, error)
	GetKey(id string, status knox.VersionStatus) (*knox.Key, error)
	AddNewKey(*knox.Key) error
	DeleteKey(id string) error
	UpdateAccess(string, knox.Access) error
	AddVersion(string, *knox.KeyVersion) error
	UpdateVersion(keyID string, versionID uint64, s knox.VersionStatus) error
}

KeyManager is the interface for logic related to managing keys.

func NewKeyManager

func NewKeyManager(c keydb.Cryptor, db keydb.DB) KeyManager

NewKeyManager builds a struct for interfacing with the keydb.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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