auth

package
v0.2.56 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCookieKey = "go_admin_session"

Variables

This section is empty.

Functions

func GetSessionByKey

func GetSessionByKey(sesKey, key string, conn db.Connection) interface{}

GetSessionByKey get the session value by key.

Types

type Config

type Config struct {
	Expires time.Duration
	Cookie  string
}

Config wraps the Session info.

type DBDriver

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

DBDriver is a driver which uses database as a persistence tool.

func (*DBDriver) Load

func (driver *DBDriver) Load(sid string) map[string]interface{}

Load implements the PersistenceDriver.Load.

func (*DBDriver) Update

func (driver *DBDriver) Update(sid string, values map[string]interface{})

Update implements the PersistenceDriver.Update.

type PersistenceDriver

type PersistenceDriver interface {
	Load(string) map[string]interface{}
	Update(sid string, values map[string]interface{})
}

PersistenceDriver is a driver of storing and getting the session info.

type Session

type Session struct {
	Expires time.Duration
	Cookie  string
	Values  map[string]interface{}
	Driver  PersistenceDriver
	Sid     string
	Context *context.Context
}

Session contains info of session.

func InitSession

func InitSession(ctx *context.Context, conn db.Connection) *Session

InitSession return the default Session.

func (*Session) Add

func (ses *Session) Add(key string, value interface{})

Add add the session value of key.

func (*Session) Clear

func (ses *Session) Clear()

Clear clear a Session.

func (*Session) Get

func (ses *Session) Get(key string) interface{}

Get get the session value.

func (*Session) StartCtx

func (ses *Session) StartCtx(ctx *context.Context) *Session

StartCtx return a Session from the given Context.

func (*Session) UpdateConfig

func (ses *Session) UpdateConfig(config Config)

UpdateConfig update the Expires and Cookie of Session.

func (*Session) UseDriver

func (ses *Session) UseDriver(driver PersistenceDriver)

UseDriver set the driver of the Session.

Jump to

Keyboard shortcuts

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