httpauth

package module
v0.0.0-...-8d253fd Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2016 License: MIT Imports: 5 Imported by: 0

README

httpauth

Package httpauth provides a goa middleware that implements Basic HTTP authentication.

License Godoc

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))

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

type ValidationFunc func(ctx *goa.Context, username, password string) error

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.

Jump to

Keyboard shortcuts

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