Added Insecure HTTP Mode

This commit is contained in:
Tim Schuster 2017-03-16 20:08:15 +01:00
parent e85636f4b9
commit 53039e6102
No known key found for this signature in database
GPG Key ID: F9E27097EFB77F61
3 changed files with 8 additions and 11 deletions

View File

@ -47,4 +47,4 @@ func handleLogin(w http.ResponseWriter, r *http.Request) {
session.Add(sess, w)
http.Redirect(w, r, "/admin/panel.html", http.StatusSeeOther)
}
}

View File

@ -2,12 +2,16 @@ package middle
import (
"github.com/icza/session"
"go.rls.moe/nyx/config"
"net/http"
)
func init() {
func SetupSessionManager(c *config.Config) {
session.Global.Close()
session.Global = session.NewCookieManager(session.NewInMemStore())
session.Global = session.NewCookieManagerOptions(session.NewInMemStore(),
&session.CookieMngrOptions{
AllowHTTP: c.DisableSecurity,
})
}
func GetSession(r *http.Request) session.Session {

View File

@ -14,14 +14,6 @@ import (
"time"
)
var riceConf = rice.Config{
LocateOrder: []rice.LocateMethod{
rice.LocateWorkingDirectory,
rice.LocateEmbedded,
rice.LocateAppended,
},
}
func Start(config *config.Config) error {
err := admin.LoadTemplates()
if err != nil {
@ -35,6 +27,7 @@ func Start(config *config.Config) error {
if err != nil {
return err
}
middle.SetupSessionManager(config)
r := chi.NewRouter()