如何为 IdentityServer4 配置登录 UI? [英] How to Configure login UI for IdentityServer4?
问题描述
我为 IdentityServer4 找到的示例使用 MVC 作为登录 UI.当 OpenIdConnect 隐式客户端访问authorization_endpoint"时(例如http://localhost:5000/connect/authorize') 它被重定向到 AccountController 登录操作.您将如何配置 IdentityServer4 以使用不同的控制器或 UI 作为登录页面?
Examples I find for IdentityServer4 use MVC for login UI. When a OpenIdConnect implicit client hits the 'authorization_endpoint' (example 'http://localhost:5000/connect/authorize') it gets redirected to the AccountController Login action. How would you configure IdentityServer4 to use a different controller or UI for as the login page?
推荐答案
在 ConfigureServices 方法下(在 Startup 中)添加一个 SetupIdentityServer 选项方法:
Under the ConfigureServices method (in Startup) add in a SetupIdentityServer options method:
services.AddIdentityServer(*SetupIdentityServer*)
.AddSigningCredential(...)
.AddValidationKeys()
.AddConfigurationStore(builder => builder.UseSqlServer(""))
.AddOperationalStore(builder => builder.UseSqlServer(""))
.AddAspNetIdentity<ApplicationUser>();
...其中 SetupIdentityServer 是您可以设置登录 url 的方法的名称:
...where SetupIdentityServer is the name of a method where you can set the login url:
private static void SetupIdentityServer(IdentityServerOptions identityServerOptions)
{
identityServerOptions.UserInteraction.LoginUrl = "/Controller/Action";
}
这篇关于如何为 IdentityServer4 配置登录 UI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!