Documentation ¶
Overview ¶
Package authdb provides a standard interface to an authentication user store to be used by AuthHandlers.
Index ¶
Constants ¶
const PBKDF2KeyLength = 20
PBKDF2KeyLength is the key length, in bytes, of the PBKDF2 keys used by CouchDB.
const SchemePBKDF2 = "pbkdf2"
SchemePBKDF2 is the default CouchDB password scheme.
Variables ¶
This section is empty.
Functions ¶
func CreateAuthToken ¶
CreateAuthToken hashes a username, salt, timestamp, and the server secret into an authentication token.
func DecodeAuthToken ¶
DecodeAuthToken decodes an auth token, extracting the username and token token creation time. To validate the authenticity of the token, use ValidatePBKDF2().
func ValidatePBKDF2 ¶
ValidatePBKDF2 returns true if the calculated hash matches the derivedKey.
Types ¶
type UserContext ¶
type UserContext struct { Database string `json:"db,omitempty"` Name string `json:"name"` Roles []string `json:"roles"` // Salt is needed to calculate cookie tokens. Salt string `json:"-"` }
UserContext represents a CouchDB UserContext object. See http://docs.couchdb.org/en/2.0.0/json-structure.html#userctx-object.
func (*UserContext) MarshalJSON ¶
func (c *UserContext) MarshalJSON() ([]byte, error)
MarshalJSON satisfies the json.Marshaler interface.
type UserStore ¶
type UserStore interface { // Validate returns a user context object if the credentials are valid. An // error must be returned otherwise. A Not Found error must not be returned. // Not Found should be treated identically to Unauthorized. Validate(ctx context.Context, username, password string) (user *UserContext, err error) // UserCtx returns a user context object if the user exists. It is used by // AuthHandlers that don't validate the password (e.g. Cookie auth). UserCtx(ctx context.Context, username string) (user *UserContext, err error) }
A UserStore provides an AuthHandler with access to a user store for.
Directories ¶
Path | Synopsis |
---|---|
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. |
Package confadmin provides an authentication service for admins configured in server configuration.
|
Package confadmin provides an authentication service for admins configured in server configuration. |
Package couchauth provides auth services to a remote CouchDB server.
|
Package couchauth provides auth services to a remote CouchDB server. |
Package usersdb provides auth facilities from a CouchDB _users database.
|
Package usersdb provides auth facilities from a CouchDB _users database. |