v1.1.0 Latest Latest

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

Go to latest
Published: Aug 17, 2017 License: MIT Imports: 16 Imported by: 0




View Source
const SimpleProviderName = "simple"

SimpleProviderName const with the providers name


This section is empty.


func ProviderList

func ProviderList() []string

ProviderList returns the names of all registered provider

func RegisterProvider

func RegisterProvider(desc *ProviderDescription, factoryMethod Provider)

RegisterProvider registers a factory method by the provider name.


type Backend

type Backend interface {
	// Authenticate checks the username/password against the backend.
	// On success it returns true and a UserInfo object which has at least the username set.
	// If the credentials do not match, false is returned.
	// The error parameter is nil, unless a communication error with the backend occurred.
	Authenticate(username, password string) (bool, model.UserInfo, error)

Backend is an loginsrv authentication extension

func SimpleBackendFactory

func SimpleBackendFactory(config map[string]string) (Backend, error)

SimpleBackendFactory returns a new configured SimpleBackend

type Config

type Config struct {
	Host           string
	Port           string
	LogLevel       string
	TextLogging    bool
	JwtSecret      string
	JwtExpiry      time.Duration
	JwtRefreshes   int
	SuccessURL     string
	LogoutURL      string
	Template       string
	LoginPath      string
	CookieName     string
	CookieExpiry   time.Duration
	CookieDomain   string
	CookieHTTPOnly bool
	Backends       Options
	Oauth          Options
	GracePeriod    time.Duration

Config for the loginsrv handler

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig for the loginsrv handler

func ReadConfig

func ReadConfig() *Config

ReadConfig from the commandline args

func (*Config) ConfigureFlagSet

func (c *Config) ConfigureFlagSet(f *flag.FlagSet)

ConfigureFlagSet adds all flags to the supplied flag set

type Handler

type Handler struct {
	// contains filtered or unexported fields

Handler is the mail login handler. It serves the login ressource and does the authentication against the backends or oauth provider.

func NewHandler

func NewHandler(config *Config) (*Handler, error)

NewHandler creates a login handler based on the supplied configuration.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Options

type Options map[string]map[string]string

Options is the configuration structure for oauth and backend provider key is the providername, value is a options map.

type Provider

type Provider func(config map[string]string) (Backend, error)

Provider is a factory method for creation of login backends.

func GetProvider

func GetProvider(providerName string) (Provider, bool)

GetProvider returns a registered provider by its name. The bool return parameter indicated, if there was such a provider.

type ProviderDescription

type ProviderDescription struct {
	// the name of the provider
	Name string

	// the text for the commandline option
	HelpText string

ProviderDescription holds the provider metadata for the help message.

func GetProviderDescription

func GetProviderDescription(providerName string) (*ProviderDescription, bool)

GetProviderDescription returns the metainfo for a provider

type SimpleBackend

type SimpleBackend struct {
	// contains filtered or unexported fields

SimpleBackend working on a map of username password pairs

func NewSimpleBackend

func NewSimpleBackend(userPassword map[string]string) *SimpleBackend

NewSimpleBackend creates a new SIMPLE Backend and verifies the parameters.

func (*SimpleBackend) Authenticate

func (sb *SimpleBackend) Authenticate(username, password string) (bool, model.UserInfo, error)

Authenticate the user

Jump to

Keyboard shortcuts

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