相关疑难解决方法(0)

会话 cookie 集`SameSite=None; 安全;`不起作用

我添加了 SameSite=None; 安全的; 设置cookie。但未设置 cookie,我无法登录我的网站。

response.writeHead(200, {
  'Content-Type': 'application/json',
  'Set-Cookie': 'token=' + token + '; SameSite=None; Secure; Expires=' + time.toUTCString() + '; Path=/' + '; Domain=' + hostname,
  'csrf-token': csrfToken
});
Run Code Online (Sandbox Code Playgroud)

我在应用程序>存储>Cookies 下的开发人员工具中查看了 cookie,并查看了更多详细信息。它显示了一条警告消息:

此 set-cookie 被阻止,因为它不是通过安全连接发送的

chrome 会阻止 cookie,因为我在开发环境中工作并发送 http 请求。但是这个在 Firefox 浏览器上的测试是正确登录的。
我把这个词保证该cookie里面和它的工作正常,但因为这个词保证,必须在下一个用来samesite =无用于跨来源,否则该cookie将被阻止。
我的问题是为什么当我使用secure 时,只有 Chrome 浏览器会阻止 cookie,但在其他浏览器中确实如此。而且,如果我不使用安全,我将无法测试支付网关,因为如果我不使用安全,它会阻止 Chrome 跨域......

javascript cookies samesite csrf-token

7
推荐指数
2
解决办法
4854
查看次数

成功登录后身份服务器不会重定向

我正在尝试使用 MVC 客户端设置 IdentityServer4。

一切正常,直到我想添加 ASP 标识。当我添加代码以使用 SQL 服务器和身份时,在成功登录后身份服务器不会将我重定向回我的客户端,而只是“刷新”页面。

IdentityServer 应用程序启动:

 public class Startup
    {
        public IWebHostEnvironment Environment { get; }

        public IConfiguration Configuration { get; }

        public Startup(IWebHostEnvironment environment, IConfiguration configuration)
        {
            Environment = environment;
            Configuration = configuration;
        }

        public void ConfigureServices(IServiceCollection services)
        {
            // uncomment, if you want to add an MVC-based UI
            services.AddControllersWithViews();

            services.AddDbContext<NebankaDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity<NebankaUser, IdentityRole>()
               .AddEntityFrameworkStores<NebankaDbContext>()
               .AddDefaultTokenProviders();

            services.AddAuthentication()
                .AddGoogle("Google", options =>
                {
                    options.SignInScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme;

                    options.ClientId = "695872592852-tc9u84trcicjuhrrei1ikdmriarl3gmf.apps.googleusercontent.com";
                    options.ClientSecret = "sVDWez0nZHEzLiSyx165YToF";
                });

            var builder …
Run Code Online (Sandbox Code Playgroud)

c# openid asp.net-core identityserver4 asp.net-core-3.0

5
推荐指数
1
解决办法
3981
查看次数