我正在将 Azure AD 与 OpenIdConnect 和一个回复 URL 网站结合使用,但我需要通过 LocalHost 进行连接以进行测试并实现其他功能。
如何使用 UseOpenIdConnectAuthentication 获得多个回复 URL,并且不会丢失两者的访问权限。
我的应用程序配置了 Asp.Net Web.Forms (Visual Studio 2015)。
谢谢。
维莱拉
最佳答案
是的,可以使用RedirectToIdentityProvider
动态更改回复URL。您可以引用下面的代码示例:
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
RedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
},
RedirectToIdentityProvider=(context)=>
{
context.ProtocolMessage.RedirectUri = "";
return Task.FromResult(0);
}
}
});
但是,如果应用程序已部署到 Web 服务器,则将重定向 URL 更改为 localhost 可能无法按您的预期工作,因为运行的 Web 应用程序有两个不同的应用程序服务器。
关于asp.net - 使用 OpenIDConnect 在 Azure AD 应用程序中回复 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40850686/