【问题标题】:How to use ASP.NET Core Identity UI with custom Authentication service instead Services.AddDefaultIdentity如何使用带有自定义身份验证服务的 ASP.NET Core Identity UI 而不是 Services.AddDefaultIdentity
【发布时间】:2022-11-27 22:08:32
【问题描述】:

Microsoft.AspNetCore.Identity.UI.dll (net6.0) 包含一系列有用的页面

但任何示例都使用默认身份,类似的东西

 Builder.Services.AddDefaultIdentity(Of IdentityUser)(Sub(options) options.SignIn.RequireConfirmedAccount = True).AddEntityFrameworkStores(Of ApplicationDbContext)

这个Identity基于IdentityUser(从ApplicationUser扩展而来)和与DB相关的EF内存缓冲区。

这种方式不适用于我的项目。我有 Scoped 服务可以通知我 - 密码是否正确,当前用户有什么角色等等。

我可以将此身份页面用于我的服务 UserService 吗?没有 IdentityUser 和 EF (Of IdentityUser) 的定义。
我如何在 DI 容器中初始化服务以使用 IdentityUI 而不是简单使用

    App.UseAuthentication()
    App.UseAuthorization()

或者 IdentityUI 根本不适用于自定义用户身份识别服务?
我可以将 UseAuthentication/UseAuthorization 与我的自定义用户识别服务一起使用吗?

【问题讨论】:

  • 我想做同样的事情……我会试一试,然后告诉你
  • @FuMe,我已经解决了这个问题,我会在周末将解决方案发布到 Github 并在那里放置链接。
  • 伟大的!我什至没有尝试过,所以我很高兴看到你是如何解决这个问题的!
  • @FuMe 如果你还有兴趣,请看我的解决方案github.com/Alex-1557/CustomIdentityInsteadDefaultIdentity

标签: c# authentication authorization asp.net-identity asp.net-core-6.0


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-23
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    • 2018-02-24
    • 1970-01-01
    • 2018-12-30
    • 2016-07-05
    相关资源
    最近更新 更多