如何将最终用户自助注册添加到 IdentityServer?

问题描述 投票:0回答:3

我想我终于足够了解 OAuth/OIDC/IdentityServer/IdMgr/IUA/ASP.NET Identity 来认识我的问题的答案。

任何人都可以向我指出 IdentityServer 3 或 4 的全功能最终用户自助注册示例/附加组件吗?

我了解管理 UI 产品。我正在寻找一个最终用户,而不是管理员,自我注册和联系信息管理 UI,类似于 MVC 项目中的个人用户帐户。

我还希望功能(包括 UI)驻留在 STS 上并与 STS OIDC 授权功能集成。

IdentityServer 3 或 4 的用户注册插件会让我很开心。

或者,IdentityServer 的全面交钥匙最终用户自助注册是否真的不存在?

我已经审查并运行了 IdSvr3 AspNetIdentity 集成示例。如果有最终用户自助注册,我看不到它。

我看过一些示例,展示了如何将最终用户自助注册页面添加到身份服务器,但它们看起来更像是一种黑客攻击,而不是全面的用户自助注册/联系信息管理功能,ALA MVC 个人用户帐户。

使用 .NET Core Web 应用中托管的 IdentityServer4 作为 STS 是我探索过的一个选项。我在那里也没有找到任何完整的示例。

identityserver4 claims-based-identity identityserver3
3个回答
0
投票

简单的答案是,购买他们的 AdminUI 解决方案。 https://www.identityserver.com/products/#AdminUI

如果你不想购买它,答案是你必须深入研究其复杂性并自己构建它。


0
投票

Skoruba admin IdentityServer4 附加组件具有最终用户自助注册功能。

Nahid Farrokhi 的 Web API 和 MVC 文章,请参阅下面的链接,解释如何配置 IdSvr4 和 .NET Framework 4.5.2 MVC 和 Web API 以协同工作。

https://nahidfa.com/posts/identityserver4-and-asp-.net-web-api/

https://nahidfa.com/posts/identityserver4-and-asp-.net-mvc/


0
投票

我做了什么(你可以将其应用于 MVC 项目):

身份服务器:

启动.cs

services.AddIdentityServer(options =>  {     
 options.Discovery.CustomEntries.Add("local_api", "~/api"); // <--
})
.AddInMemoryClients(Config.Clients)
    ...

控制器/UserController.cs

[Route("api/[controller]")]
[Authorize(IdentityServer4.IdentityServerConstants.LocalApi.PolicyName)]
public class UserController : ControllerBase
{
  [HttpPost("create_user")]
  [AllowAnonymous]
  public async Task<ActionResult<string>> CreateUser([FromBody] CreateApplicationUserViewModel newUser)
  {
      if (newUser.Email != null)
      {
        string result = await _userService.CreateUserAsync(newUser);
        return Ok(result);
      }

      return BadRequest("Email is missing");
  }
}


服务/UserService.cs

public class UserService : IUserService
{
   private readonly ApplicationDbContext _dbContext;
   private readonly UserManager<ApplicationUser> _userManager;
   private readonly IMapper _mapper;

   public UserService(ApplicationDbContext dbContext,serManager<ApplicationUser> userManager)
   {
      _userManager = userManager;
      _dbContext = dbContext;
      _mapper = mapper;
   }

   public async Task<string> CreateUserAsync(CreateApplicationUserViewModel newUser)
   {
       if (newUser.Email != null && await _userManager.FindByEmailAsync(newUser.Email) == null)
       {
           ApplicationUserViewModel appViewModel = _mapper.Map<ApplicationUserViewModel>(newUser);
           ApplicationUser newAppUser = _mapper.Map<ApplicationUser>(appViewModel);
           newAppUser.UserName = newUser.Email; // Add this if you want that user should login with E-Mail and not Username

           IdentityResult result = await _userManager.CreateAsync(newAppUser, newUser.Password);

            if (result.Succeeded)
            {
               return "User is created";

            }else
            {
               return "Problem with user creation";
            } 
       }

       return "This e-mail address is already taken.";
   }

... 

// Add here other operations for User like Update or Delete
 
}

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.