【问题标题】:Integration between Two IdentityServer4 (aspnet identity)两个 IdentityServer4 之间的集成(aspnet 身份)
【发布时间】:2019-08-08 19:39:10
【问题描述】:

我正在尝试将 IdentityServer4(A) 与另一个 IdentityServer4(B) 实现集成。这两个目前彼此独立工作。

我已经在这方面取得了一些进展,但我觉得我没有以正确的方式做这件事。 IdentityServer(A)

  • 添加了一个新客户端(AllowedGrantTypes = GrantTypes.Implicit,

IdentityServer(B)

  • 添加了新的身份验证源AddOpenIdConnect
.AddOpenIdConnect("oidc", "Identity Server A", options =>
{
  options.SignInScheme = IdentityConstants.ExternalScheme;
  options.SignOutScheme = IdentityServerConstants.SignoutScheme;
  options.SaveTokens = true;
  options.RequireHttpsMetadata = false;

  options.Authority = "http://localhost:5000";
  options.ClientId = "identityServerB";

  options.GetClaimsFromUserInfoEndpoint = true;
  options.Scope.Add("roles");

  options.Events.OnTokenValidated = async ctx =>
  {
    ctx.Principal.Claims.Append(new Claim("LoginSource", "IdentityServerA"));

  };
});

目前的结果是,在B上使用外部登录机制后

  • 正在按预期在 B 上创建帐户,
  • 用户已在 A 上注销
  • B aspneUser 表未填充来自 A 的用户数据
  • B 使用用户数据填充用户声明表。

在这个阶段,我需要一种方法或最佳实践来实现这一点:

  1. 在不存在的情况下创建A到B,B到A的账户。
  2. 从源合并创建的帐户,或者只是一种链接ID的方式
  3. 无论身份验证来源如何,都能访问身份服务器客户端。
  4. 关联角色或任何声明以识别登录源。
  5. 更新用户信息并重置密码

【问题讨论】:

  • 在您的情况下,两个身份提供者之间的集成可以通过使用外部 idp 来完成,就像您可以使用 google 或 facebook 作为任何常规身份服务器实施的外部 idp。

标签: asp.net-identity single-sign-on identityserver4 claims-based-identity asp.net-core-2.1


【解决方案1】:

您要实现的目标称为联合网关。

什么是联合网关,为什么需要它? http://docs.identityserver.io/en/latest/topics/federation_gateway.html

如何实现联邦网关? http://docs.identityserver.io/en/latest/quickstarts/4_external_authentication.html

【讨论】:

  • 谢谢!昨天我能够配置 B 以正确的方式创建帐户和声明。快速入门中有“ExternalController”,您可以在回调上管理和开发自定义工作流程。但是我仍然存在用户在 A 上注销的问题,并且我无法使用在 B 上创建的帐户自动登录。没有关于如何实现这一点的文档存在一些差距。只有注释 [link]docs.identityserver.io/en/latest/quickstarts/… 有点帮助... :(
【解决方案2】:

通过联合网关文档解决的问题 http://docs.identityserver.io/en/latest/quickstarts/4_external_authentication.html

使用 4_ImplicitFlowAuthenticationWithExternal 快速入门来识别和修复问题。

External Authentication QuickStart

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-23
    • 1970-01-01
    • 2018-05-12
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    相关资源
    最近更新 更多