goETS is an implementation of the Encrypted Token Paturn Session written for Negroni middleware.
- MaxAge - is the max length of time in seconds that a session token is valid
- CryptKey - is the secret 256 bit AES key
// Setting up the session options
var sOpt = new(session.Options)
// Set the max age of the session in seconds
sOpt.MaxAge = 30 * 60 // 30min * 60 sec/min
// This is only a test key, the key needs to be secret.
sOpt.CryptKey = []byte("n+D+LpWrHpjzhe4HyPdALAbwrB4vk1WV")
n := negroni.Classic()
// Using the session middleware in Negroni
n.Use(session.NewSession(sOpt))
context.Set(req, session.CONTEXT_KEY, "1")
context.Set(req, session.CONTEXT_KEY, "")
sesStr := context.Get(req, session.CONTEXT_KEY).(string)