2015-01-29 05:10:34 -06:00
|
|
|
package middleware
|
|
|
|
|
2015-04-07 12:21:14 -05:00
|
|
|
import (
|
2018-03-06 16:59:45 -06:00
|
|
|
ms "github.com/go-macaron/session"
|
2016-01-13 08:38:54 -06:00
|
|
|
"gopkg.in/macaron.v1"
|
2015-04-07 12:21:14 -05:00
|
|
|
|
2018-03-06 16:59:45 -06:00
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
|
|
|
"github.com/grafana/grafana/pkg/services/session"
|
2015-01-29 05:10:34 -06:00
|
|
|
)
|
2015-04-07 12:21:14 -05:00
|
|
|
|
2018-03-15 15:23:33 -05:00
|
|
|
func Sessioner(options *ms.Options, sessionConnMaxLifetime int64) macaron.Handler {
|
|
|
|
session.Init(options, sessionConnMaxLifetime)
|
2015-04-07 12:21:14 -05:00
|
|
|
|
2018-03-07 10:54:50 -06:00
|
|
|
return func(ctx *m.ReqContext) {
|
2015-04-07 12:21:14 -05:00
|
|
|
ctx.Next()
|
|
|
|
|
2018-03-06 16:59:45 -06:00
|
|
|
if err := ctx.Session.Release(); err != nil {
|
2015-04-07 12:21:14 -05:00
|
|
|
panic("session(release): " + err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|