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!
const DefaultInsecureSecret = "They're all gonna laugh at you!"
DefaultSessionTimeout is the default session timeout, in seconds, used if couch_httpd_auth.timeout is inuset.
const DefaultSessionTimeout = 600
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"} )
func BindParams(r *http.Request, i interface{}) error
BindParams binds the request form or JSON body to the provided struct.
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(r *http.Request, key string) (string, bool)
StringQueryParam extracts a query parameter as string.
Service defines a CouchDB-like service to serve. You will define one of these per server endpoint.
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 }
func GetService(r *http.Request) *Service
GetService extracts the Kivik service from the request.
func (s *Service) Bind(addr string) error
Bind sets the HTTP daemon bind address and port.
func (s *Service) Conf() *conf.Conf
Conf returns the initialized server configuration.
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 (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 (s *Service) Start() error
Start begins serving connections.
func (s *Service) ValidateCookie(user *authdb.UserContext, cookie string) (bool, error)
ValidateCookie validates a cookie against a user context.
Name | Synopsis |
---|---|
.. | |
auth | Package auth manages authorization and authentication for kivikd. |
basic | 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 |
authdb | 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. |
confadmin | Package confadmin provides an authentication service for admins configured in server configuration. |
couchauth | Package couchauth provides auth services to a remote CouchDB server. |
usersdb | Package usersdb provides auth facilities from a CouchDB _users database. |
conf | Package conf manages configuration for kivikd. |
cookies | Package cookies provides cookies utilities. |
couchserver | Package couchserver aims to provide a CouchDB-compatible HTTP server interface to a kivik.Client. |
logger | Package logger defines the logger used by kivikd. |
test | Package test configures the integration test suite for kivikd. |