kivikd

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2017 License: Apache-2.0 Imports: 22 Imported by: 3

README

Build Status Codecov Go Report Card GoDoc

Kivikd

Package kivikd aims to provide a CouchDB-compatible daemon, backed by the Kivik suite of drivers. The primary goal is to provide a simple stand-alone server process for testing.

What is the development status?

Kivikd is in early-stage development. Very little functionality is complete.

What license is Kivikd released under?

This software is released under the terms of the Apache 2.0 license. See LICENCE.md, or read the full license.

Documentation

Index

Constants

View Source
const DefaultInsecureSecret = "They're all gonna laugh at you!"

DefaultInsecureSecret is the hash secret used if couch_httpd_auth.secret is unconfigured. Please configure couch_httpd_auth.secret, or they're all gonna laugh at you!

View Source
const DefaultSessionTimeout = 600

DefaultSessionTimeout is the default session timeout, in seconds, used if couch_httpd_auth.timeout is inuset.

Variables

View Source
var (
	// SessionKey is a context key used to access the authenticated session.
	SessionKey = &contextKey{"session"}
	// ClientContextKey is a context key used to access the kivik client.
	ClientContextKey = &contextKey{"client"}
	// ServiceContextKey is a context key used to access the serve.Service struct.
	ServiceContextKey = &contextKey{"service"}
)

Functions

func BindParams

func BindParams(r *http.Request, i interface{}) error

BindParams binds the request form or JSON body to the provided struct.

func MustGetSession

func MustGetSession(ctx context.Context) *auth.Session

MustGetSession returns the user context for the currently authenticated user. If no session is set, the function panics.

func StringQueryParam

func StringQueryParam(r *http.Request, key string) (string, bool)

StringQueryParam extracts a query parameter as string.

Types

type Service

type Service struct {
	// Client is an instance of a driver.Client, which will be served.
	Client *kivik.Client
	// UserStore provides access to the user database. This is passed to auth
	// handlers, and is used to authenticate sessions. If unset, a nil UserStore
	// will be used which authenticates all uses. PERPETUAL ADMIN PARTY!
	UserStore authdb.UserStore
	// AuthHandler is a slice of authentication handlers. If no auth
	// handlers are configured, the server will operate as a PERPETUAL
	// ADMIN PARTY!
	AuthHandlers []auth.Handler
	// CompatVersion is the compatibility version to report to clients. Defaults
	// to 1.6.1.
	CompatVersion string
	// VendorVersion is the vendor version string to report to clients. Defaults to the library
	// version.
	VendorVersion string
	// VendorName is the vendor name string to report to clients. Defaults to the library
	// vendor string.
	VendorName string
	// Favicon is the path to a file to serve as favicon.ico. If unset, a default
	// image is used.
	Favicon string
	// RequestLogger receives logging information for each request.
	RequestLogger logger.RequestLogger

	// ConfigFile is the path to a config file to read during startup.
	ConfigFile string

	// Config is a complete config object. If this is set, config loading is
	// bypassed.
	Config *conf.Conf
	// contains filtered or unexported fields
}

Service defines a CouchDB-like service to serve. You will define one of these per server endpoint.

func GetService

func GetService(r *http.Request) *Service

GetService extracts the Kivik service from the request.

func (*Service) Bind

func (s *Service) Bind(addr string) error

Bind sets the HTTP daemon bind address and port.

func (*Service) Conf

func (s *Service) Conf() *conf.Conf

Conf returns the initialized server configuration.

func (*Service) CreateAuthToken

func (s *Service) CreateAuthToken(name, salt string, time int64) (string, error)

CreateAuthToken hashes a user name, salt, timestamp, and the server secret into an authentication token.

func (*Service) Init

func (s *Service) Init() (http.Handler, error)

Init initializes a configured server. This is automatically called when Start() is called, so this is meant to be used if you want to bind the server yourself.

func (*Service) Start

func (s *Service) Start() error

Start begins serving connections.

func (*Service) ValidateCookie

func (s *Service) ValidateCookie(user *authdb.UserContext, cookie string) (bool, error)

ValidateCookie validates a cookie against a user context.

Directories

Path Synopsis
basic
Package basic provides HTTP Basic Auth services.
Package basic provides HTTP Basic Auth services.
cookie
Package cookie provides standard CouchDB cookie auth as described at http://docs.couchdb.org/en/2.0.0/api/server/authn.html#cookie-authentication
Package cookie provides standard CouchDB cookie auth as described at http://docs.couchdb.org/en/2.0.0/api/server/authn.html#cookie-authentication
Package authdb provides a standard interface to an authentication user store to be used by AuthHandlers.
Package authdb provides a standard interface to an authentication user store to be used by AuthHandlers.
authgroup
Package authgroup groups two or more authentication backends together, trying one, then falling through to the others.
Package authgroup groups two or more authentication backends together, trying one, then falling through to the others.
confadmin
Package confadmin provides an authentication service for admins configured in server configuration.
Package confadmin provides an authentication service for admins configured in server configuration.
couchauth
Package couchauth provides auth services to a remote CouchDB server.
Package couchauth provides auth services to a remote CouchDB server.
usersdb
Package usersdb provides auth facilities from a CouchDB _users database.
Package usersdb provides auth facilities from a CouchDB _users database.
Package couchserver aims to provide a CouchDB-compatible HTTP server interface to a kivik.Client.
Package couchserver aims to provide a CouchDB-compatible HTTP server interface to a kivik.Client.

Jump to

Keyboard shortcuts

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