Updated the Login code so it responds with a set-cookie header for the session token. Still looking into if this is the right thing to do however.

This commit is contained in:
2021-01-03 02:36:36 -06:00
parent e8454fb652
commit 26ea8e8cbc
28 changed files with 31 additions and 7037 deletions
+14 -1
View File
@@ -1,5 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using System;
using System.Web;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@@ -15,8 +17,19 @@ namespace SecureCore.Controllers
public IActionResult Login(LoginInfo info)
{
var (hash, salt) = Authentication.HashPassword(info.Password);
var options = new CookieOptions
{
Domain = "copyrightcrusader.org",
Expires = DateTime.Now.AddDays(7),
HttpOnly = true,
Secure = true,
Path = "/",
SameSite = SameSiteMode.Strict
};
return Ok($"Session Key: {Authentication.CreateSessionId()}{Environment.NewLine}Password Hash: {hash}{Environment.NewLine}Salt: {salt}{Environment.NewLine}");
HttpContext.Response.Cookies.Append("Session", Authentication.CreateSessionToken(), options);
return Ok();
}
}
}