dynamodbstore

package module
v0.0.0-...-08ec8b6 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2016 License: MIT Imports: 13 Imported by: 0

README

dynamodbstore

Session store for Gorilla Sessions backed by DynamoDB using the official Go AWS SDK.

Proper documentation / release coming when I get a moment 😀

Feel free to take it now though, MIT Licenced.

Acknowledgement to several other Gorilla Session libraries that this is heavily based on

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamoDBStore

type DynamoDBStore struct {
	Db            *dynamodb.DynamoDB
	Table         string
	Codecs        []securecookie.Codec
	Options       *sessions.Options // default configuration
	DefaultMaxAge int               // default TTL for a MaxAge == 0 session
	// contains filtered or unexported fields
}

DynamoDBStore stores sessions in a DynamoDB table.

func NewDynamoDBStore

func NewDynamoDBStore(db *dynamodb.DynamoDB, sessionCookieExpireTime int, sessionTableName string, readCapacityUnits int64, writeCapacityUnits int64, keyPairs ...[]byte) (*DynamoDBStore, error)

NewDynamoDBStore returns a new DynamoDBStore. sessionCookieExpireTime controls how long a session will live in the database when it is set to 0 seconds expire time aka session cookie sessionTableName is name of dynamodb table to use - is created if it does not exist. If created, readCapacityUnits and writeCapacityUnits are used

func (*DynamoDBStore) Get

func (s *DynamoDBStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns a session for the given name after adding it to the registry.

See gorilla/sessions FilesystemStore.Get().

func (*DynamoDBStore) New

func (s *DynamoDBStore) New(r *http.Request, name string) (*sessions.Session, error)

New returns a session for the given name without adding it to the registry.

See gorilla/sessions FilesystemStore.New().

func (*DynamoDBStore) Save

Save adds a single session to the response.

func (*DynamoDBStore) SetMaxAge

func (s *DynamoDBStore) SetMaxAge(v int)

SetMaxAge restricts the maximum age, in seconds, of the session record both in database and a browser. This is to change session storage configuration. If you want just to remove session use your session `s` object and change it's `Options.MaxAge` to -1, as specified in

http://godoc.org/github.com/gorilla/sessions#Options

Default is the one provided by this package value - `sessionExpire`. Set it to 0 for no restriction. Because we use `MaxAge` also in SecureCookie crypting algorithm you should use this function to change `MaxAge` value.

func (*DynamoDBStore) SetSerializer

func (s *DynamoDBStore) SetSerializer(ss SessionSerializer)

SetSerializer sets the serializer

type GobSerializer

type GobSerializer struct{}

GobSerializer uses gob package to encode the session map

func (GobSerializer) Deserialize

func (s GobSerializer) Deserialize(d []byte, ss *sessions.Session) error

Deserialize back to map[interface{}]interface{}

func (GobSerializer) Serialize

func (s GobSerializer) Serialize(ss *sessions.Session) ([]byte, error)

Serialize using gob

type SessionSerializer

type SessionSerializer interface {
	Deserialize(d []byte, ss *sessions.Session) error
	Serialize(ss *sessions.Session) ([]byte, error)
}

SessionSerializer provides an interface hook for alternative serializers

Jump to

Keyboard shortcuts

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