auth

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2017 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//LocalClientSessionMode for SessionToken auth only
	LocalClientSessionMode = iota
	//LocalClientBasicAuthMode for Basic auth only
	LocalClientBasicAuthMode
)

Variables

This section is empty.

Functions

func CheckPersistentSession

func CheckPersistentSession(db *sql.DB, store sessionstore.Store, headers http.Header, ctx *context.Context) bool

CheckPersistentSession check persistent session token from CLI

func GetUsername

func GetUsername(store sessionstore.Store, token string) (string, error)

GetUsername retrieve the username from the token

func NewPersistentSession

func NewPersistentSession(db *sql.DB, d Driver, u *sdk.User) (sessionstore.SessionKey, error)

NewPersistentSession create a new session with token stored as user_key in database

func NewSession

func NewSession(d Driver, u *sdk.User) (sessionstore.SessionKey, error)

NewSession inits a new session

Types

type Driver

type Driver interface {
	Open(options interface{}, store sessionstore.Store) error
	Store() sessionstore.Store
	Authentify(username, password string) (bool, error)
	AuthentifyUser(user *sdk.User, password string) (bool, error)
	GetCheckAuthHeaderFunc(options interface{}) func(db *sql.DB, headers http.Header, c *context.Context) error
}

Driver is an interface to all auth method (local, ldap and beyond...)

func GetDriver

func GetDriver(mode string, options interface{}, storeOptions sessionstore.Options) (Driver, error)

GetDriver is a factory

type Entry

type Entry struct {
	DN         string
	Attributes map[string]string
}

Entry represents a LDAP entity

type LDAPClient

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

LDAPClient enbeddes the LDAP connecion

func (*LDAPClient) Authentify

func (c *LDAPClient) Authentify(username, password string) (bool, error)

Authentify check username and password

func (*LDAPClient) AuthentifyUser

func (c *LDAPClient) AuthentifyUser(u *sdk.User, password string) (bool, error)

AuthentifyUser check password in database

func (*LDAPClient) Bind

func (c *LDAPClient) Bind(username, password string) error

Bind binds

func (*LDAPClient) Close

func (c *LDAPClient) Close()

Close the specified client

func (*LDAPClient) GetCheckAuthHeaderFunc

func (c *LDAPClient) GetCheckAuthHeaderFunc(options interface{}) func(db *sql.DB, headers http.Header, ctx *context.Context) error

GetCheckAuthHeaderFunc returns the func to heck http headers. Options is a const to switch from session to basic auth or both

func (*LDAPClient) Open

func (c *LDAPClient) Open(options interface{}, store sessionstore.Store) error

Open open a true LDAP connection

func (*LDAPClient) Search

func (c *LDAPClient) Search(filter string, attributes ...string) ([]Entry, error)

Search search

func (*LDAPClient) Store

func (c *LDAPClient) Store() sessionstore.Store

Store returns store

type LDAPConfig

type LDAPConfig struct {
	Host         string
	Port         int
	Base         string
	DN           string
	SSL          bool
	UserFullname string
}

LDAPConfig handles all config to connect to the LDAP

type LDAPDriver

type LDAPDriver interface {
	Open(c LDAPConfig) error
	Close() error
	Search(filter string, attributes ...string) ([]Entry, error)
}

LDAPDriver is the LDAP client interface

type LocalClient

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

LocalClient is a auth driver wich store all in database

func (*LocalClient) Authentify

func (c *LocalClient) Authentify(username, password string) (bool, error)

Authentify check username and password

func (*LocalClient) AuthentifyUser

func (c *LocalClient) AuthentifyUser(u *sdk.User, password string) (bool, error)

AuthentifyUser check password in database

func (*LocalClient) GetCheckAuthHeaderFunc

func (c *LocalClient) GetCheckAuthHeaderFunc(options interface{}) func(db *sql.DB, headers http.Header, ctx *context.Context) error

GetCheckAuthHeaderFunc returns the func to heck http headers. Options is a const to switch from session to basic auth or both

func (*LocalClient) Open

func (c *LocalClient) Open(options interface{}, store sessionstore.Store) error

Open nothing

func (*LocalClient) Store

func (c *LocalClient) Store() sessionstore.Store

Store returns store

Jump to

Keyboard shortcuts

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