angular - 多租户和 IdentityServer 4 和 Angular 和 oidc-client
问题描述
我们正在使用 Angular 6 开发一个多租户应用程序。每个租户使用他们的子域访问应用程序,比如client1.app.com
,client2.app.com
等等。
出于身份验证目的,我们使用 IdentityServer 4。我们遵循的步骤类似于以下提到的步骤:https ://identityserver4.readthedocs.io/en/release/quickstarts/7_javascript_client.html 。
一切正常 - 我们坚持的一点是我们如何redirect_uri
在 Angular 客户端应用程序中指定 。
如您所知,redirect-uri
Identity Server 使用它来返回身份验证结果和信息。根据oidc-client
库,它redirect_uri
是一个字符串,我们不能指定多个值。但是,在我们的案例中,基于客户端的子域,情况redirect-uri
会有所不同,并且必须是动态的。
有没有人遇到过类似的情况?我忽略了什么吗?任何解决上述问题的指针都会有很大帮助。
谢谢苏希尔
解决方案
您需要redirect_uri
在客户端中设置从主机解析(使用window.location
或您想在此处使用的任何解决方案)。然后每个租户在访问 Identity Server 时都会传递这个 URI。
在 Identity Server 端,在 Client 对象中,该RedirectUris
属性是一个集合,因此您应该在其中添加所有租户的重定向 uri(也不要忘记PostLogoutRedirectUris
)。
推荐阅读
- javascript - 具有不同过滤器的条件 .filter() 函数
- linux - 临时文件夹用完了 inode
- binary-search - 我们可以使用线性搜索而不是二分搜索来查找插入位置,而不会产生任何显着的运行时间损失吗?
- javascript - Angular - 在组件中动态加载没有 script.src 的脚本
- python - 使用 Python Selenium,当有多个时,如何从单个选择下拉菜单中选择一个项目?
- python - 如何在 python 中使用 panda datareader 将数据从每日更改为每月?
- wordpress - 在 Wordpress 中的挂钩内定义简码
- angular - 为什么 Nativescript 中的 AbstractControl 根属性自引用?
- python - 如何使用python代码在json文件中自动输出(1200索引)
- css - 角度材质进度条未从主题加载原色