auth

package
v0.0.0-...-424292f Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2018 License: BSD-3-Clause Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ContextUser contextKey = iota
	ContextHatchery
	ContextWorker
	ContextService
	ContextUserSession
	ContextProvider
)

Variables

This section is empty.

Functions

func CheckServiceAuth

func CheckServiceAuth(ctx context.Context, db *gorp.DbMap, store cache.Store, headers http.Header) (context.Context, error)

CheckServiceAuth checks services authentication

func CheckWorkerAuth

func CheckWorkerAuth(ctx context.Context, db *gorp.DbMap, store cache.Store, headers http.Header) (context.Context, error)

CheckWorkerAuth checks worker authentication

func ContextValues

func ContextValues(ctx context.Context) map[interface{}]interface{}

ContextValues retuns auth values of a context

func GetService

func GetService(db *gorp.DbMap, store cache.Store, hash string) (*sdk.Service, error)

GetService returns the service instance from its hash

func GetUsername

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

GetUsername retrieve the username from the token

func GetWorker

func GetWorker(db *gorp.DbMap, store cache.Store, workerID, workerName string) (*sdk.Worker, error)

GetWorker returns the worker instance from its id

func NewPersistentSession

func NewPersistentSession(db gorp.SqlExecutor, 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
	CheckAuth(ctx context.Context, w http.ResponseWriter, req *http.Request) (context.Context, error)
	Authentify(username, password string) (bool, error)
}

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

func GetDriver

func GetDriver(c context.Context, mode string, options interface{}, storeOptions sessionstore.Options, DBFunc func() *gorp.DbMap) (Driver, error)

GetDriver is a factory

func TestLocalAuth

func TestLocalAuth(t *testing.T, db *gorp.DbMap, o sessionstore.Options) Driver

type Entry

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

Entry represents a LDAP entity

type GithubClient

type GithubClient struct{}

GithubClient is a github impl

func (*GithubClient) Authentify

func (c *GithubClient) Authentify(db gorp.SqlExecutor, username, password string) (bool, error)

Authentify check username and password

type GithubConfig

type GithubConfig struct {
	ClientID     string
	ClientSecret string
}

GithubConfig handles all config to connect to the github

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

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

Bind binds

func (*LDAPClient) CheckAuth

func (c *LDAPClient) CheckAuth(ctx context.Context, w http.ResponseWriter, req *http.Request) (context.Context, error)

func (*LDAPClient) Close

func (c *LDAPClient) Close()

Close the specified client

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
	BindDN       string
	BindPwd      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 which store all in database

func (*LocalClient) Authentify

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

Authentify check username and password

func (*LocalClient) CheckAuth

CheckAuth checks the auth

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