Documentation ¶
Index ¶
- Variables
- func AddDefaultAccess(a *knox.Access)
- func AddHeader(k, v string) func(http.HandlerFunc) http.HandlerFunc
- func Authentication(providers []auth.Provider) func(http.HandlerFunc) http.HandlerFunc
- func GetAPIError(r *http.Request) *httpError
- func GetPrincipal(r *http.Request) knox.Principal
- func GetRouteID(r *http.Request) string
- func GetRouter(cryptor keydb.Cryptor, db keydb.DB, ...) *mux.Router
- func Logger(logger *log.Logger) func(http.HandlerFunc) http.HandlerFunc
- type KeyManager
Constants ¶
This section is empty.
Variables ¶
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"}, knox.BadKeyFormatCode: &httpErrResp{http.StatusBadRequest, "Key ID contains unsupported characters"}, }
HTTPErrMap is a mapping from err subcodes to the http err response that will be returned.
Functions ¶
func AddDefaultAccess ¶
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 ¶
GetAPIError gets the HTTP error that will be returned from the server.
func GetPrincipal ¶
GetPrincipal gets the principal authenticated through the authentication decorator
func GetRouteID ¶
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.