auth

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: GPL-3.0, GPL-3.0-or-later Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthenticationProvider

type AuthenticationProvider interface {
	// Init initialize the provider
	Init()
	// AuthenticateMiddleware return the middleware used to check if the users are authenticated
	AuthenticateMiddleware(next http.Handler) http.Handler
	// TokenEndpoint return the middleware used to check if the users are authenticated
	GetToken(w http.ResponseWriter, r *http.Request)
	// GetUserInfoIfCorrect return the informations about the user if the provided credentials are correct, otherwise return nil
	GetUserInfoIfCredentialsAreCorrect(username string, password string) (map[string]interface{}, utils.AdvancedErrorInterface)
}

AuthenticationProvider is a interface that wrap methods used to authenticate users

func BuildAuthenticationProvider

func BuildAuthenticationProvider(conf config.AuthenticationProviderConfig, timeNow func() time.Time, log *logrus.Logger) AuthenticationProvider

BuildAuthenticationProvider return a authentication provider that match what is requested in the configuration It's initialized

type BasicAuthenticationProvider

type BasicAuthenticationProvider struct {
	// Config contains the dataservice global configuration
	Config config.AuthenticationProviderConfig
	// TimeNow contains a function that return the current time
	TimeNow func() time.Time
	// Log contains logger formatted
	Log *logrus.Logger
	// contains filtered or unexported fields
}

BasicAuthenticationProvider is the concrete implementation of AuthenticationProvider that provide a simple user authentication.

func (*BasicAuthenticationProvider) AuthenticateMiddleware

func (ap *BasicAuthenticationProvider) AuthenticateMiddleware(next http.Handler) http.Handler

AuthenticateMiddleware return the middleware used to check if the users are authenticated

func (*BasicAuthenticationProvider) GetToken

GetToken return the middleware used to check if the users are authenticated

func (*BasicAuthenticationProvider) GetUserInfoIfCredentialsAreCorrect

func (ap *BasicAuthenticationProvider) GetUserInfoIfCredentialsAreCorrect(username string, password string) (map[string]interface{}, utils.AdvancedErrorInterface)

GetUserInfoIfCredentialsAreCorrect return the informations about the user if the provided credentials are correct, otherwise return nil

func (*BasicAuthenticationProvider) Init

func (ap *BasicAuthenticationProvider) Init()

Init initializes the service and database

type LDAPAuthenticationProvider

type LDAPAuthenticationProvider struct {
	// Config contains the dataservice global configuration
	Config config.AuthenticationProviderConfig
	// TimeNow contains a function that return the current time
	TimeNow func() time.Time
	// Log contains logger formatted
	Log *logrus.Logger

	Client *ldap.LDAPClient
	// contains filtered or unexported fields
}

LDAPAuthenticationProvider is the concrete implementation of AuthenticationProvider that provide a LDAP user authentication.

func (*LDAPAuthenticationProvider) AuthenticateMiddleware

func (ap *LDAPAuthenticationProvider) AuthenticateMiddleware(next http.Handler) http.Handler

AuthenticateMiddleware return the middleware used to check if the users are authenticated

func (*LDAPAuthenticationProvider) GetToken

GetToken return the middleware used to check if the users are authenticated

func (*LDAPAuthenticationProvider) GetUserInfoIfCredentialsAreCorrect

func (ap *LDAPAuthenticationProvider) GetUserInfoIfCredentialsAreCorrect(username string, password string) (map[string]interface{}, utils.AdvancedErrorInterface)

GetUserInfoIfCredentialsAreCorrect return the informations about the user if the provided credentials are correct, otherwise return nil

func (*LDAPAuthenticationProvider) Init

func (ap *LDAPAuthenticationProvider) Init()

Init initializes the service and database

Jump to

Keyboard shortcuts

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