我正在使用 Azure Active Directory 身份验证构建 MVC 应用程序。当我在本地开发时,我希望能够登录以进行测试/开发。应用程序网址就像http://localhost:43400
。这也被编码在 AD 应用程序中Sign-On Url
and Reply Url
.
当我将相同的应用程序部署到服务器时,应用程序 url 发生更改 - 变成类似myappname.azurewebsites.net
我无法使用相同的 AD 应用程序登录。我能做到的最好办法就是完成登录过程,但随后 AD 将我重定向回localhost:43400
这是错误的。
有PostLogoutRedirectUri
财产在Startup.Auth.cs
我给了应用程序,但这根本没有区别。
有没有办法让本地应用程序和部署的应用程序使用相同的 Azure AD?
我可以使用不同的 url 和键执行 2 AND 应用程序,并重写其中的值web.config
部署时。但这听起来并不是最好的解决方案。我还能做些什么吗?
UPD
这是我提到的一点Startup.Auth.cs
:
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = Authority,
PostLogoutRedirectUri = postLogoutRedirectUri, // <-- this is coming from web.config, different in dev and prod
Notifications = new OpenIdConnectAuthenticationNotifications()
{
.....
}
});
查看完整的代码清单here.
And in Azure AD application I tried both addresses as a Reply URL at the same time:
但是,即使客户端指定了与其中一项记录匹配的重定向,AD 也仅使用其中一个地址进行重定向。