authatron

package module
v0.0.0-...-597dad4 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2015 License: MIT Imports: 9 Imported by: 0

README

Authatron 1000

Go Authentication Handling For Sizema/Moni-Tron

GoDoc

Documentation

Overview

Package Authatron provides authentication interfaces for authenticating users in go. Currently fake (fixed password) and LDAP authentication is supported.

Configuration

Authatron supports configuration by creating an AuthConfig programmatically, a default empty config can be created using NewLDAPAuthenticatorFromConfig. AuthConfig is marked up using struct tags to be loaded from a toml file using: https://github.com/BurntSushi/toml

Configuration can also be loaded from environment variables using UpdateConfigFromEnvironmentVariables which can take a prefix to configure a prefix for the environment variables.

Interface

Once configured NewAuthenticateServiceFromConfig can be used to create a new AuthenticateService. The AuthenticateService consists of two smaller interfaces the UserStore and Authenticator. The UserStore is responsible for storing and retrieving user credentials and the Authenticator is responsible for initially authenticating a user.

UserStore - Currently the only implementation of UserStore is a cookie user store using http://github.com/gorilla/securecookie.

Authenticator - There are currently two Authenticator implementations

  • 'dummy' which allows a password to be set and will authenticate all users using that password.
  • 'ldap' which authenticates users against and LDAP server.

Integrating

Soon...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLDAPAuthenticatorFromConfig

func NewLDAPAuthenticatorFromConfig(config LDAPAuthConfig) ldapAuthenticator

NewLDAPAuthenticatorFromConfig creates a new Authenticator from the provided LDAPAuthConfig

Types

type AuthConfig

type AuthConfig struct {
	// Select the authentication engine
	Type string `toml:"type"`
	DummyAuthConfig
	LDAPAuthConfig
	UserStoreConfig
}

Configuration object for configuring Authatron.

func DefaultAuthConfig

func DefaultAuthConfig() AuthConfig

DefaultAuthConfig returns a default AuthConfig that enables dummy authentication.

func UpdateConfigFromEnvironmentVariables

func UpdateConfigFromEnvironmentVariables(prefix string, config AuthConfig) AuthConfig

UpdateConfigFromEnvironmentVariables returns an updated config updated loading in any environment variables. Environment variables can be prefixed using prefix allowing individual applications to namespace env vars

type AuthenticateService

type AuthenticateService interface {
	UserStore
	Authenticator
}

func NewAuthenticateService

func NewAuthenticateService() AuthenticateService

func NewAuthenticateServiceFromConfig

func NewAuthenticateServiceFromConfig(config *AuthConfig) (AuthenticateService, error)

NewAuthenticateServiceFromConfig creates a new AuthenticateService using the provided config struct

type Authenticator

type Authenticator interface {
	// Authenticate checks the provided username and password returning
	// a User if successful
	Authenticate(username, password string) (User, error)
}

Authenticator interface for any authentication backend this wishes to authenticate a user

type DummyAuthConfig

type DummyAuthConfig struct {
	DummyPassword string `toml:"dummy-password"`
}

type LDAPAuthConfig

type LDAPAuthConfig struct {
	Host                 string `toml:"host"`
	Port                 uint16 `toml:"port"`
	BindDN               string `toml:"bind_dn"`
	BindPassword         string `toml:"bind_password"`
	BaseDN               string `toml:"base_dn"`
	UserNameLookupFilter string `toml:"username_lookup"`
}

Configuration object for configuring an LDAP connection.

type User

type User interface {
	UserID() string
}

Interface that describes a logged in user.

type UserStore

type UserStore interface {
	// Store the provided user in the session provided by request.
	StoreUserForRequest(w http.ResponseWriter, r *http.Request, user User) error

	// Retrieve the users details for this request, if no user is logged
	// in the User returned is nil
	RetrieveUserFromRequest(r *http.Request) (User, error)

	// Retrieve the users details from the provided auth key, if no user is
	// logged in the User return is nil
	RetrieveUserFromAuthKey(authKey string) (User, error)

	// ForgetUserForRequest removes the details of the current logged in
	// user for this session
	ForgetUserForRequest(w http.ResponseWriter, r *http.Request) error
}

UserStore is an interface for storing/retrieving user details

type UserStoreConfig

type UserStoreConfig struct {
	CookieSecret string `toml:"cookie-secret"`
	StoreName    string `toml:"store-name"`
}

Jump to

Keyboard shortcuts

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