gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

memstore.go (925B)


      1 package memstore
      2 
      3 import (
      4 	"github.com/gin-contrib/sessions"
      5 	"github.com/quasoft/memstore"
      6 )
      7 
      8 type Store interface {
      9 	sessions.Store
     10 }
     11 
     12 // Keys are defined in pairs to allow key rotation, but the common case is to set a single
     13 // authentication key and optionally an encryption key.
     14 //
     15 // The first key in a pair is used for authentication and the second for encryption. The
     16 // encryption key can be set to nil or omitted in the last pair, but the authentication key
     17 // is required in all pairs.
     18 //
     19 // It is recommended to use an authentication key with 32 or 64 bytes. The encryption key,
     20 // if set, must be either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256 modes.
     21 func NewStore(keyPairs ...[]byte) Store {
     22 	return &store{memstore.NewMemStore(keyPairs...)}
     23 }
     24 
     25 type store struct {
     26 	*memstore.MemStore
     27 }
     28 
     29 func (c *store) Options(options sessions.Options) {
     30 	c.MemStore.Options = options.ToGorillaOptions()
     31 }