目前,这是有效的,我正在使用Identity在ASP MVC Core 2应用程序中设置cookie身份验证:
services.ConfigureApplicationCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(1);
options.SlidingExpiration = true;
options.LoginPath = "/Account/LogIn";
options.LogoutPath = "/Account/LogOff";
options.Cookie.Name = "MyCookieName";
options.AccessDeniedPath = "/Account/AccessDenied";
});
我想将JWT添加到此应用程序,并根据文档here,我通过使用类似的东西(基于与上面相同的配置)来做到这一点:
services.AddAuthentication()
.AddCookie(options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(1);
options.SlidingExpiration = true;
options.LoginPath = "/Account/LogIn";
options.LogoutPath = "/Account/LogOff";
options.Cookie.Name = "MyCookieName";
options.AccessDeniedPath = "/Account/AccessDenied";
})
.AddJwtBearer(options =>
{ // options });
当我这样做时(即使我离开AddJwtBearer
链),cookie也不再被赋予我指定的名称。登录过程仍然有效,我得到一个cookie,但它被命名为默认的Asp cookie名称。
我认为这两种设置选项的方法是相同的,而ConfigureApplicationCookie
只是同一事物的快捷方法。
我错过了什么吗?
谢谢, 布赖恩
答案 0 :(得分:0)
尝试以下方法:
Configutation:
name: Default
Properties:
Property:
name: log-path
value: "logs"
Appenders:
Console:
name: Console_Appender
target: SYSTEM_OUT
PatternLayout:
pattern: "[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"
Loggers:
Root:
level: warn
AppenderRef:
- ref: Console_Appender
Logger:
- name: org.apache.kafka
level: info
AppenderRef:
- ref: Console_Appender