Versions in this module Expand all Collapse all v1 v1.0.1 Jul 17, 2019 v1.0.0 Jul 10, 2019 Changes in this version + const DefaultTokenLength + const DriverNameCacheStore + const DriverNameClientStore + const FlagDefault + const FlagTemporay + const IVSize + const PrefixModeEmpty + const PrefixModeMd5 + const PrefixModeRaw + const StoreModeCookie + const StoreModeHeader + var DefaultMarshaler = "msgpack" + var ErrDataNotFound = errors.New("Data not found") + var ErrDataTypeWrong = errors.New("Data type wrong") + var ErrFeatureNotSupported = errors.New("Feature is not supported") + var ErrNilPointer = errors.New("Data point to nil") + var ErrRequestTokenNotFound = errors.New("Request token not found.Did you forget use install middleware?") + var ErrTokenNotValidated = errors.New("Token not validated") + func AESDecrypt(encrypted []byte, key []byte, iv []byte) (decrypted []byte, err error) + func AESDecryptBase64(encrypted string, key []byte, iv []byte) (decrypted []byte, err error) + func AESEncrypt(unencrypted []byte, key []byte, iv []byte) (encrypted []byte, err error) + func AESEncryptBase64(unencrypted []byte, key []byte, iv []byte) (encrypted string, err error) + func AESNonceDecrypt(encrypted []byte, key []byte) (decrypted []byte, err error) + func AESNonceDecryptBase64(encrypted string, key []byte) (decrypted []byte, err error) + func AESNonceEncrypt(unencrypted []byte, key []byte) (encrypted []byte, err error) + func AESNonceEncryptBase64(unencrypted []byte, key []byte) (encrypted string, err error) + func AESTokenMarshaler(s *ClientDriver, ts *Session) (err error) + func AESTokenUnmarshaler(s *ClientDriver, v *Session) (err error) + func PKCS7Padding(data []byte, blockSize int) []byte + func PKCS7Unpadding(data []byte) []byte + type CacheDriver struct + Cache *cache.Cache + Length int + PrefixMode string + TokenGenerater func(s *CacheDriver, prefix string) (token string, err error) + func NewCacheDriver() *CacheDriver + func (s *CacheDriver) Close() error + func (s *CacheDriver) ConvertPrefix(prefix string) (output string, err error) + func (s *CacheDriver) Delete(token string) error + func (s *CacheDriver) GenerateToken(prefix string) (token string, err error) + func (s *CacheDriver) GetSessionToken(ts *Session) (token string, err error) + func (s *CacheDriver) Init(option CacheDriverOption) error + func (s *CacheDriver) Load(v *Session) (err error) + func (s *CacheDriver) Save(ts *Session, ttl time.Duration) (err error) + type CacheDriverOption interface + ApplyTo func(*CacheDriver) error + type CacheDriverOptionConfig struct + Cache *cache.Cache + Length int + PrefixMode string + func NewCacheDriverOptionConfig() *CacheDriverOptionConfig + func (o *CacheDriverOptionConfig) ApplyTo(d *CacheDriver) error + type ClientDriver struct + Key []byte + TokenMarshaler func(*ClientDriver, *Session) error + TokenUnmarshaler func(*ClientDriver, *Session) error + func NewClientDriver() *ClientDriver + func (s *ClientDriver) Close() error + func (s *ClientDriver) Delete(token string) error + func (s *ClientDriver) GenerateToken(prefix string) (token string, err error) + func (s *ClientDriver) GetSessionToken(ts *Session) (token string, err error) + func (s *ClientDriver) Init(option ClientDriverOption) error + func (s *ClientDriver) Load(v *Session) (err error) + func (s *ClientDriver) Save(ts *Session, ttl time.Duration) (err error) + type ClientDriverOption interface + ApplyTo func(*ClientDriver) error + type ClientDriverOptionConfig struct + Key []byte + func NewClientDriverOptionConfig() *ClientDriverOptionConfig + func (o *ClientDriverOptionConfig) ApplyTo(d *ClientDriver) error + type ContextKey string + type Driver interface + Close func() error + Delete func(token string) error + GenerateToken func(owner string) (token string, err error) + GetSessionToken func(ts *Session) (token string, err error) + Load func(v *Session) error + Save func(t *Session, ttl time.Duration) error + type Field struct + Name string + Store *Store + func (f *Field) Flush(r *http.Request) (err error) + func (f *Field) Get(r *http.Request, v interface{}) (err error) + func (f *Field) GetSession(r *http.Request) (ts *Session, err error) + func (f *Field) IdentifyRequest(r *http.Request) (string, error) + func (f *Field) LoadFrom(ts *Session, v interface{}) (err error) + func (f *Field) Login(w http.ResponseWriter, r *http.Request, id string) error + func (f *Field) Logout(w http.ResponseWriter, r *http.Request) error + func (f *Field) SaveTo(ts *Session, v interface{}) (err error) + func (f *Field) Set(r *http.Request, v interface{}) (err error) + type Flag uint64 + type Option interface + ApplyTo func(*Store) error + type OptionConfig struct + Driver Driver + TokenLifetime time.Duration + func NewOptionConfig() *OptionConfig + func (o *OptionConfig) ApplyTo(s *Store) error + type ResponseWriter interface + type Session struct + CreatedTime int64 + ExpiredAt int64 + Flag Flag + LastActiveTime int64 + Mutex *sync.RWMutex + Nonce []byte + Store *Store + func NewSession(token string, s *Store) *Session + func (s *Session) Del(name string) (err error) + func (s *Session) DeleteAndSave() error + func (s *Session) Get(name string, v interface{}) (err error) + func (s *Session) HasFlag(flag Flag) bool + func (s *Session) Load() error + func (s *Session) Marshal() ([]byte, error) + func (s *Session) MustToken() string + func (s *Session) Regenerate() + func (s *Session) RegenerateToken(owner string) error + func (s *Session) Save() error + func (s *Session) Set(name string, v interface{}) (err error) + func (s *Session) SetCache(name string, v interface{}) + func (s *Session) SetFlag(flag Flag, value bool) + func (s *Session) SetToken(newToken string) + func (s *Session) Token() (string, error) + func (s *Session) Unmarshal(token string, bytes []byte) error + type Store struct + AutoGenerate bool + CookieName string + CookiePath string + CookieSecure bool + DefaultSessionFlag Flag + Driver Driver + Marshaler cache.Marshaler + Mode string + TokenContextName ContextKey + TokenLifetime time.Duration + TokenMaxLifetime time.Duration + UpdateActiveInterval time.Duration + func MustCacheStore(Cache *cache.Cache, TokenLifetime time.Duration) *Store + func MustClientStore(key []byte, TokenLifetime time.Duration) *Store + func New() *Store + func (s *Store) AutoGenerateMiddleware() func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + func (s *Store) Close() error + func (s *Store) CookieMiddleware() func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + func (s *Store) Del(r *http.Request, fieldName string) (err error) + func (s *Store) DeleteToken(token string) error + func (s *Store) DestoryMiddleware() func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + func (s *Store) ExpiredAt(r *http.Request) (ExpiredAt int64, err error) + func (s *Store) Field(name string) *Field + func (s *Store) GenerateSession(token string) (ts *Session, err error) + func (s *Store) GenerateToken(prefix string) (token string, err error) + func (s *Store) Get(r *http.Request, fieldName string, v interface{}) (err error) + func (s *Store) GetRequestSession(r *http.Request) (ts *Session, err error) + func (s *Store) GetSession(token string) (ts *Session) + func (s *Store) GetSessionToken(ts *Session) (token string, err error) + func (s *Store) HeaderMiddleware(Name string) func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + func (s *Store) Init(option Option) error + func (s *Store) Install(r *http.Request, token string) (ts *Session, err error) + func (s *Store) InstallMiddleware() func(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) + func (s *Store) LoadSession(v *Session) error + func (s *Store) RegenerateToken(prefix string) (ts *Session, err error) + func (s *Store) SaveRequestSession(r *http.Request) error + func (s *Store) SaveSession(t *Session) error + func (s *Store) Set(r *http.Request, fieldName string, v interface{}) (err error) + func (s Store) IsNotFoundError(err error) bool + type StoreConfig struct + AutoGenerate bool + Cache cache.OptionConfigMap + ClientStoreKey string + CookieName string + CookiePath string + CookieSecure bool + DefaultSessionFlag Flag + DriverName string + Marshaler string + Mode string + TokenContextName string + TokenLength int + TokenLifetimeInDay int64 + TokenLifetimeInHour int64 + TokenMaxLifetimeInDay int64 + TokenPrefixMode string + UpdateActiveIntervalInSecond int64 + func (s *StoreConfig) ApplyTo(store *Store) error