使用 IdentityServer 4 和 Angular 使用 oidc-client 的多租户
Multi-tenancy with and IdentityServer 4 and Angular with oidc-client
我们正在使用 Angular 6 开发多租户应用程序。每个租户都使用他们的子域访问该应用程序,例如 client1.app.com
、client2.app.com
等
出于身份验证目的,我们使用的是 IdentityServer 4。我们遵循的步骤类似于以下提到的步骤:https://identityserver4.readthedocs.io/en/release/quickstarts/7_javascript_client.html。
一切正常 - 我们坚持的一点是我们如何在 Angular 客户端应用程序中指定 redirect_uri
。
如您所知,身份服务器使用 redirect-uri
来 return 返回身份验证结果和信息。根据 oidc-client
库,redirect_uri
是一个字符串,我们不能指定多个值。然而,在我们的例子中,基于客户端的子域,redirect-uri
会有所不同并且必须是动态的。
有没有人遇到过类似的情况?我忽略了什么吗?解决上述问题的任何指示都会有很大帮助。
谢谢
苏希尔
您需要在客户端中设置 redirect_uri
以从主机解析(使用 window.location
或您想在此处使用的任何解决方案)。那么每个租户在访问Identity Server时都会通过这个URI。
在 Identity Server 端,在 Client 对象中,RedirectUris
属性 是一个集合,因此您应该在其中添加所有租户的重定向 uri(不要忘记 PostLogoutRedirectUris
也是)。
我们正在使用 Angular 6 开发多租户应用程序。每个租户都使用他们的子域访问该应用程序,例如 client1.app.com
、client2.app.com
等
出于身份验证目的,我们使用的是 IdentityServer 4。我们遵循的步骤类似于以下提到的步骤:https://identityserver4.readthedocs.io/en/release/quickstarts/7_javascript_client.html。
一切正常 - 我们坚持的一点是我们如何在 Angular 客户端应用程序中指定 redirect_uri
。
如您所知,身份服务器使用 redirect-uri
来 return 返回身份验证结果和信息。根据 oidc-client
库,redirect_uri
是一个字符串,我们不能指定多个值。然而,在我们的例子中,基于客户端的子域,redirect-uri
会有所不同并且必须是动态的。
有没有人遇到过类似的情况?我忽略了什么吗?解决上述问题的任何指示都会有很大帮助。
谢谢 苏希尔
您需要在客户端中设置 redirect_uri
以从主机解析(使用 window.location
或您想在此处使用的任何解决方案)。那么每个租户在访问Identity Server时都会通过这个URI。
在 Identity Server 端,在 Client 对象中,RedirectUris
属性 是一个集合,因此您应该在其中添加所有租户的重定向 uri(不要忘记 PostLogoutRedirectUris
也是)。