login

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const SimpleProviderName = "simple"

SimpleProviderName const with the providers name

Variables

This section is empty.

Functions

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.

Types

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
	JwtAlgo                string
	JwtExpiry              time.Duration
	JwtRefreshes           int
	SuccessURL             string
	Redirect               bool
	RedirectQueryParameter string
	RedirectCheckReferer   bool
	RedirectHostFile       string
	LogoutURL              string
	Template               string
	LoginPath              string
	CookieName             string
	CookieExpiry           time.Duration
	CookieDomain           string
	CookieHTTPOnly         bool
	CookieSecure           bool
	Backends               Options
	Oauth                  Options
	GracePeriod            time.Duration
	UserFile               string
}

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) GetToken added in v1.2.3

func (h *Handler) GetToken(r *http.Request) (userInfo model.UserInfo, valid bool)

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

type UserClaims added in v1.2.4

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

func NewUserClaims added in v1.2.4

func NewUserClaims(config *Config) (*UserClaims, error)

func (*UserClaims) Claims added in v1.2.4

func (c *UserClaims) Claims(userInfo model.UserInfo) (jwt.Claims, error)

Claims returns a map of the token claims for a user.

Jump to

Keyboard shortcuts

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