authentication

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package authentication implements a very minimal HTTP Basic Auth header verification mechanism.

Before it can operate it needs to load the credentials from a backend via LoadCredentials().

Currently supported backends:

a CredentialsStore variable directly
a Reader which can deliver data as specified in LoadCredentialsFromReader()

Once credentials are loaded the main functionality is available via BasicAuthPassed() which can report if a given Authorization header matches any of the loaded credentials.

Index

Constants

View Source
const (
	NotAttempted
	NotBasic
	Failed
	Passed
)

The possible statuses of authentication process

Variables

This section is empty.

Functions

func BasicAuthPassed

func BasicAuthPassed(r *http.Request) (status int, user string)

BasicAuthPassed verifies an authHeader to see if it passed HTTP Basic Auth.

func Hash

func Hash(str string) (hash string)

Hash generates a hash of the given string. Used for hashing passwords.

func LoadCredentials

func LoadCredentials(backend interface{}) (err error)

LoadCredentials loads the given credentials into the library.

func LoadCredentialsFromReader

func LoadCredentialsFromReader(r io.Reader) (err error)

LoadCredentialsFromReader loads the credentials from the given r io.Reader into the library. The file must have the format:

username:sha256_of_password

Types

type CredentialsStore

type CredentialsStore map[string]string

CredentialsStore defines the storage type for credentials.

Jump to

Keyboard shortcuts

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