Documentation ¶
Overview ¶
Package httpauth provides a goa middleware that implements Basic HTTP authentication.
Middleware ¶
The package provides a middleware that can be mounted to services or controllers that require authentication. The basic authentication middleware is instantiated using the BasicMiddleware function. This function accepts a specification that describes how the middleware should operate.
spec := &httpauth.Specification{ LogFailure: true, LogSuccess: true, Realm: "Restricted", ValidationFunc: authHandler, } service.Use(httpauth.BasicMiddleware(spec)) // or protectedController.Use(httpauth.BasicMiddleware(spec))
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicMiddleware ¶
func BasicMiddleware(spec *Specification) goa.Middleware
BasicMiddleware is a middleware that provides Basic HTTP authentication.
Types ¶
type Specification ¶
type Specification struct { ValidationProvider ValidationFunc // The auth realm Realm string // Log successful authentications. LogSuccess bool // Log failed authentications. LogFailure bool }
Specification describes the HTTP auth properties.
type ValidationFunc ¶
ValidationFunc is a function type that takes a goa context along with a username and password. Returning nil denotes success. The goa context is available in case information needs to be inserted into the context.