auth

package
v0.0.0-...-e9b977e Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthN

type AuthN interface {
	Authenticate(string) (bool, error)
}

AuthN is an authentication provider.

It is responsible for taking raw HTTP Authorization data and determining whether the request is authenticated.

type BasicAuth

type BasicAuth struct {
	Users UserPasswordLookup
}

BasicAuth is an authentication provider for type HTTP Basic Auth.

func (*BasicAuth) Authenticate

func (a *BasicAuth) Authenticate(data string) (bool, error)

Authenticate performs an authentication step on raw HTTP Authorization data.

type HTTPAuth

type HTTPAuth struct {
	Realm string
	// contains filtered or unexported fields
}

HTTPAuth provides HTTP authentication services.

func NewBasicHTTPAuth

func NewBasicHTTPAuth(pwdb UserPasswordLookup) *HTTPAuth

Create a new HTTPAuth object with HTTP Basic support.

This requires a UserPasswordLookup service.

func (*HTTPAuth) Authenticate

func (h *HTTPAuth) Authenticate(res http.ResponseWriter, req *http.Request) bool

This will attempt to authenticate, and return an HTTP error if auth fails.

If this returns `false`, a 403 Unauthorized response has already been sent.

type UserPasswordLookup

type UserPasswordLookup interface {
	// IsValid looks up a username and password, and returns true if the auth is successful.
	//
	// An error is only returned if the underlying mechanism is failing. A false
	// with a nil error means the authentication simply failed.
	IsValid(username, password string) (bool, error)
}

UserPasswordLookup provides services for lookup up a username/password combo.

Jump to

Keyboard shortcuts

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