auth

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

An Handler is an HTTP handler that verifies that incoming requests have an authenticated user and passes those that pass authentication to a child.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type Store

type Store struct {
	// contains filtered or unexported fields
}

A Store is a thread-safe collection of usernames and passwords.

func NewAuthStore

func NewAuthStore() *Store

NewAuthStore creates a new, empty Store.

func (*Store) Authenticate

func (a *Store) Authenticate(user, pass string) bool

Authenticate returns true if the specified username and password are part of the store.

func (*Store) AuthenticateBasic

func (s *Store) AuthenticateBasic(hdr string) bool

AuthenticateBasic takes an "Authorization" header and returns true if it is a valid "basic" style header and if it is valid.

func (*Store) Close

func (a *Store) Close()

Close releases any resources used by the store. It is important to call this if "Watch" was used.

func (*Store) CreateHandler

func (s *Store) CreateHandler(child http.Handler, realm string) *Handler

CreateHandler creates an HTTP handler for the specified auth store that will respond with "401 unauthorized" when no authentication is present, or pass on the request when authentication succeeds.

func (*Store) IsEmpty

func (a *Store) IsEmpty() bool

IsEmpty returns true if there is nothing in the store. We might use this to determine if we should skip authentication.

func (*Store) Load

func (s *Store) Load(fileName string) error

Load loads the specified file, replacing the contents of the current store with whatever is in the file. The file must have been generated by the "htpasswd" utility. An error will be returned if invalid file content is detected. Only passwords encoded using "bcrypt" will work -- all others will effectively be ignored.

func (*Store) Watch

func (s *Store) Watch(interval time.Duration) error

Watch periodically checks the file loaded using "Load" and re-loads it if it has changed. Reloading is done in a thread-safe way.

Jump to

Keyboard shortcuts

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