Documentation
¶
Index ¶
- Variables
- func Authenticate(r *web.Request, db *mgo.Session) (*models.User, error)
- func AuthenticateBasic(r *web.Request, db *mgo.Session) (*models.User, error)
- func AuthenticateToken(r *web.Request, db *mgo.Session, user *models.User) (*models.User, error)
- func Authorize(session *mgo.Session, user *models.User, request *web.Request) error
- type WhitelistEntry
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoDatabase is thrown if no database connection is present // during an authentication. ErrNoDatabase = errors.New("no database connection") // ErrAuthenticationRequired is thrown if no valid user authenticates // but authentication is required for the requested resource. ErrAuthenticationRequired = errors.New("authentication required") // ErrForbidden is thrown if a user is authenticated, but not // allowed to access the requested resource. ErrForbidden = errors.New("forbidden") // ErrInternalServerError is thrown if an internal problem occurs // during the authentication process at no fault of the requestor. ErrInternalServerError = errors.New("internal server error") )
var Whitelist = []WhitelistEntry{ {Method: "PUT", URL: regexp.MustCompile(`/v[0-9]+/users[/]?`)}, {Method: "POST", URL: regexp.MustCompile(`/v[0-9]+/users[/]?`)}, {Method: "GET", URL: regexp.MustCompile(`/v[0-9]+/_ping?`)}, }
Whitelist is an array of WhitelistEntry's for URLs that require no authentication or authorization.
Functions ¶
func Authenticate ¶
Authenticate is responsible for authenticating users. It current recognises both basic and token authentication (as used by the Docker client). It will either return nil,nil if no authentication is required for the page, or a user object if authentication succeeds, or an error if authentication is required but fails.
func AuthenticateBasic ¶
AuthenticateBasic attempts to authenticate users via basic auth
func AuthenticateToken ¶
AuthenticateToken allows token based access to repositories rather than basic auth as per the Docker Registry & Index Spec
Types ¶
type WhitelistEntry ¶
WhitelistEntry is a URL matcher that is used to whitelist certain HTTP method/URLs. It comprises of a Method string (eg, GET) and a regexp for matching the URL.