login

package
v0.0.0-...-9b7d049 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SimpleProviderName = "simple"

Variables

This section is empty.

Functions

func ProviderList

func ProviderList() []string

Returns the names of all registered provider

func RegisterProvider

func RegisterProvider(desc *ProviderDescription, factoryMethod Provider)

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)
}

Logsrv authentication extension

func SimpleBackendFactory

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

Returns a new configured SimpleBackend

type Config

type Config struct {
	Host                   string
	Port                   string
	LogLevel               string
	TextLogging            bool
	JwtSecret              string
	JwtSecretFile          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
	UserEndpoint           string
	UserEndpointToken      string
	UserEndpointTimeout    time.Duration
}

Config for the loginsrv handler

func DefaultConfig

func DefaultConfig() *Config

Default config for the loginsrv handler

func ReadConfig

func ReadConfig() *Config

Read config from the commandline args

func (*Config) ConfigureFlagSet

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

Adds all flags to the supplied flag set

func (*Config) ResolveFileReferences

func (c *Config) ResolveFileReferences() error

Resolves configuration values, which are dynamically referenced via files

type Handler

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

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)

Creates a login handler based on the supplied configuration

func (*Handler) GetToken

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

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)

Factory method for creation of login backends

func GetProvider

func GetProvider(providerName string) (Provider, bool)

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

type ProviderDescription

type ProviderDescription struct {
	// Name of the provider
	Name string
	// Text for the commandline option
	HelpText string
}

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
}

Working on a map of username password pairs

func NewSimpleBackend

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

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

type UserClaims interface {
	Claims(userInfo model.UserInfo) (jwt.Claims, error)
}

func NewUserClaims

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

Jump to

Keyboard shortcuts

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