如何使用身份服务器在部署的应用程序中保存 cookie?
How can i save cookies in deployed app using identity server?
我正在使用身份服务器 4 OAuth 来保护我的应用程序。在开发中一切正常。所以我在 minikube 中部署了我的应用程序并使用本地主机连接,一切仍然有效。但是当我使用 ip 从另一台 PC 连接时,cookie 没有保存,我无法登录。我需要处理任何选项才能开始保存 cookie 吗?
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews()
.AddRazorRuntimeCompilation();
services.AddIdentityServerConfiguration(_config);
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
services.AddIdentityServer()
.AddAspNetIdentity<IdentityUser>()
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b =>
b.UseNpgsql(_config.GetConnectionString(nameof(ApplicationDbContext)),
sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b =>
b.UseNpgsql(_config.GetConnectionString(nameof(ApplicationDbContext)),
sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddDeveloperSigningCredential();
services.ConfigureApplicationCookie(config =>
{
config.Cookie.Name = "IdentityServer.Cookies";
config.Cookie.HttpOnly = false;
});
}
问题出在证书上。一旦我开始使用自签名证书和 https:// 一切正常
https://docs.microsoft.com/en-us/aspnet/core/security/docker-https?view=aspnetcore-3.1
我正在使用身份服务器 4 OAuth 来保护我的应用程序。在开发中一切正常。所以我在 minikube 中部署了我的应用程序并使用本地主机连接,一切仍然有效。但是当我使用 ip 从另一台 PC 连接时,cookie 没有保存,我无法登录。我需要处理任何选项才能开始保存 cookie 吗?
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews()
.AddRazorRuntimeCompilation();
services.AddIdentityServerConfiguration(_config);
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
services.AddIdentityServer()
.AddAspNetIdentity<IdentityUser>()
.AddConfigurationStore(options =>
{
options.ConfigureDbContext = b =>
b.UseNpgsql(_config.GetConnectionString(nameof(ApplicationDbContext)),
sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddOperationalStore(options =>
{
options.ConfigureDbContext = b =>
b.UseNpgsql(_config.GetConnectionString(nameof(ApplicationDbContext)),
sql => sql.MigrationsAssembly(migrationsAssembly));
})
.AddDeveloperSigningCredential();
services.ConfigureApplicationCookie(config =>
{
config.Cookie.Name = "IdentityServer.Cookies";
config.Cookie.HttpOnly = false;
});
}
问题出在证书上。一旦我开始使用自签名证书和 https:// 一切正常 https://docs.microsoft.com/en-us/aspnet/core/security/docker-https?view=aspnetcore-3.1