好的,所以感谢Twitter上一位贡献者的帮助,我已经对它进行了分类.所以对于有同样问题的其他人来说,这就是我的工作方式.
我还必须安装第二个包IdentityServer3.Admin.EntityFramework.在github上的repo中,还有一个示例项目(https://github.com/IdentityServer/IdentityServer3.Admin.EntityFramework/tree/master/source/Host)
使用该代码作为指导,我IdentityManagerAdminService
为工厂实现了自己的扩展方法,其中"IdServer3"
我的连接字符串是我的ID Server DB Web.config
.
public class IdentityAdminManagerService : IdentityAdminCoreManager{ public IdentityAdminManagerService() : base("IdServer3") { } } public static class IdentityAdminManagerServiceExtensions { public static void Configure(this IdentityAdminServiceFactory factory) { factory.IdentityAdminService = new Registration (); } }
现在在我的Startup.cs
文件中,我有以下内容,当我点击/admin
ID服务器上的路径时,它正如预期的那样工作.注意,该WsFederationAuthentication
部分不是必需的.我正在使用Azure Active Directory来保护管理部分,这就是我在那里的原因.
app.Map("/admin", adminApp => { var factory = new IdentityAdminServiceFactory(); factory.Configure(); adminApp.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = "Cookies" }); adminApp.UseWsFederationAuthentication(new WsFederationAuthenticationOptions { MetadataAddress = ConfigurationManager.AppSettings["AzureADMetadataEndpoint"], Wtrealm = ConfigurationManager.AppSettings["AzureADApplicationId"], SignInAsAuthenticationType = "Cookies", Notifications = new WsFederationAuthenticationNotifications { SecurityTokenValidated = ctx => { var roleClaim = new Claim("role", "IdentityManagerAdministrator"); ctx.AuthenticationTicket.Identity.AddClaim(roleClaim); return Task.FromResult(0); } } }); adminApp.UseIdentityAdmin(new IdentityAdminOptions { Factory = factory, AdminSecurityConfiguration = new AdminHostSecurityConfiguration { HostAuthenticationType = "Cookies", NameClaimType = ClaimTypes.Name, RoleClaimType = "role", AdminRoleName = "IdentityManagerAdministrator" } }); });