Documentation ¶
Index ¶
- type Handler
- type Store
- func (a *Store) Authenticate(user, pass string) bool
- func (s *Store) AuthenticateBasic(hdr string) bool
- func (a *Store) Close()
- func (s *Store) CreateHandler(child http.Handler, realm string) *Handler
- func (a *Store) IsEmpty() bool
- func (s *Store) Load(fileName string) error
- func (s *Store) Watch(interval time.Duration) error
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.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
A Store is a thread-safe collection of usernames and passwords.
func (*Store) Authenticate ¶
Authenticate returns true if the specified username and password are part of the store.
func (*Store) AuthenticateBasic ¶
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 ¶
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 ¶
IsEmpty returns true if there is nothing in the store. We might use this to determine if we should skip authentication.
func (*Store) Load ¶
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.