コード例 #1
0
        public async Task SendAuthCookies(AppUser user, string refreshToken = null)
        {
            var jwt = await tokenGenerator.GenerateJwtAsync(user);

            var st = tokenGenerator.GenerateStateToken(user.UserName);

            contextAccessor.HttpContext.Response.Cookies.Append("_aid", jwt, new CookieOptions {
                Expires = DateTime.UtcNow.AddMinutes(30), HttpOnly = true, Secure = false, SameSite = SameSiteMode.Unspecified, Domain = "localhost"
            });
            contextAccessor.HttpContext.Response.Cookies.Append("_rid", refreshToken, new CookieOptions {
                Expires = DateTime.UtcNow.AddDays(2), HttpOnly = true, Secure = false, SameSite = SameSiteMode.Unspecified, Domain = "localhost"
            });
            contextAccessor.HttpContext.Response.Cookies.Append("_sid", st, new CookieOptions {
                Expires = DateTime.UtcNow.AddDays(2), HttpOnly = false, Secure = false, SameSite = SameSiteMode.Unspecified, Domain = "localhost"
            });
        }