注销后如何忽略LoggedOut页面?
How I can ignore LoggedOut page after logout?
我使用 CustomViewService。
注销后应将用户重定向到登录页面。从注销页面自动重定向不是解决方案,因为 CustomViewService 的特定实现。
public Task<Stream> LoggedOut(LoggedOutViewModel model, SignOutMessage message)
{
return Render(model, "loggedOut");
}
我的身份服务器设置示例:
public void Configuration(IAppBuilder appBuilder)
{
appBuilder.UseRequestScopeContext();
appBuilder.Map("/core", coreApp =>
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Trace()
.CreateLogger();
var factory = new IdentityServerServiceFactory();
factory
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get())
.UseInMemoryUsers(Users.Get());
factory.CorsPolicyService = new Registration<ICorsPolicyService>(new DefaultCorsPolicyService { AllowAll = true });
factory.UserService = new Registration<IUserService>(new UserService(new ApplicationDbContext()));
factory.ViewService = new Registration<IViewService, CustomViewService>();
var options = new IdentityServerOptions
{
SiteName = "MySite",
SigningCertificate = Certificate.Get(),
Factory = factory,
RequireSsl = false,
CspOptions = new CspOptions()
{
Enabled = false
},
AuthenticationOptions = new AuthenticationOptions()
{
EnableSignOutPrompt = false,
EnablePostSignOutAutoRedirect = true,
PostSignOutAutoRedirectDelay = 0,
RequireSignOutPrompt = false,
},
EnableWelcomePage = false
};
coreApp.UseIdentityServer(options);
});
}
除了您 link 的 SO post 中提到的内容之外,您还必须通过 id_token
才能使 post_logout_redirect 工作。
见https://identityserver.github.io/Documentation/docsv2/endpoints/endSession.html
我使用 CustomViewService。
注销后应将用户重定向到登录页面。从注销页面自动重定向不是解决方案,因为 CustomViewService 的特定实现。
public Task<Stream> LoggedOut(LoggedOutViewModel model, SignOutMessage message)
{
return Render(model, "loggedOut");
}
我的身份服务器设置示例:
public void Configuration(IAppBuilder appBuilder)
{
appBuilder.UseRequestScopeContext();
appBuilder.Map("/core", coreApp =>
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Trace()
.CreateLogger();
var factory = new IdentityServerServiceFactory();
factory
.UseInMemoryClients(Clients.Get())
.UseInMemoryScopes(Scopes.Get())
.UseInMemoryUsers(Users.Get());
factory.CorsPolicyService = new Registration<ICorsPolicyService>(new DefaultCorsPolicyService { AllowAll = true });
factory.UserService = new Registration<IUserService>(new UserService(new ApplicationDbContext()));
factory.ViewService = new Registration<IViewService, CustomViewService>();
var options = new IdentityServerOptions
{
SiteName = "MySite",
SigningCertificate = Certificate.Get(),
Factory = factory,
RequireSsl = false,
CspOptions = new CspOptions()
{
Enabled = false
},
AuthenticationOptions = new AuthenticationOptions()
{
EnableSignOutPrompt = false,
EnablePostSignOutAutoRedirect = true,
PostSignOutAutoRedirectDelay = 0,
RequireSignOutPrompt = false,
},
EnableWelcomePage = false
};
coreApp.UseIdentityServer(options);
});
}
除了您 link 的 SO post 中提到的内容之外,您还必须通过 id_token
才能使 post_logout_redirect 工作。
见https://identityserver.github.io/Documentation/docsv2/endpoints/endSession.html