Renamed CheckLogin to Login

Changed encryption cookie to be 32 bytes (64 bytes not supported)
pull/24/head
Jordan 2014-01-11 00:10:52 -06:00
parent 2a62f62bc6
commit cdb4181406
3 changed files with 3 additions and 6 deletions

View File

@ -20,13 +20,12 @@ func init() {
var Store = sessions.NewCookieStore( var Store = sessions.NewCookieStore(
[]byte(securecookie.GenerateRandomKey(64)), //Signing key []byte(securecookie.GenerateRandomKey(64)), //Signing key
[]byte(securecookie.GenerateRandomKey(64)), //Encryption key []byte(securecookie.GenerateRandomKey(32)))
)
// CheckLogin attempts to request a SQL record with the given username. // CheckLogin attempts to request a SQL record with the given username.
// If successful, it then compares the received bcrypt hash. // If successful, it then compares the received bcrypt hash.
// If all checks pass, this function sets the session id for later use. // If all checks pass, this function sets the session id for later use.
func CheckLogin(r *http.Request) (bool, error) { func Login(r *http.Request) (bool, error) {
username, password := r.FormValue("username"), r.FormValue("password") username, password := r.FormValue("username"), r.FormValue("password")
session, _ := Store.Get(r, "gophish") session, _ := Store.Get(r, "gophish")
stmt, err := db.Conn.Prepare("SELECT * FROM Users WHERE username=?") stmt, err := db.Conn.Prepare("SELECT * FROM Users WHERE username=?")

View File

@ -123,7 +123,7 @@ func Login(w http.ResponseWriter, r *http.Request) {
if err := r.ParseForm(); err != nil { if err := r.ParseForm(); err != nil {
http.Error(w, "Error parsing request", http.StatusInternalServerError) http.Error(w, "Error parsing request", http.StatusInternalServerError)
} }
succ, err := auth.CheckLogin(r) succ, err := auth.Login(r)
if err != nil { if err != nil {
http.Error(w, "Error logging in", http.StatusInternalServerError) http.Error(w, "Error logging in", http.StatusInternalServerError)
} }

View File

@ -27,8 +27,6 @@ func GetContext(handler http.Handler) http.HandlerFunc {
ctx.Set(r, "user", nil) ctx.Set(r, "user", nil)
} }
handler.ServeHTTP(w, r) handler.ServeHTTP(w, r)
// Save the session
session.Save(r, w)
// Remove context contents // Remove context contents
ctx.Clear(r) ctx.Clear(r)
} }