gpt4 book ai didi

asp.net - Azure Active Directory 回复 URL 重定向到根

转载 作者:行者123 更新时间:2023-12-02 07:33:58 25 4
gpt4 key购买 nike

我正在尝试使用 Azure AD 实现身份验证。在应用程序设置中,我将回复 URL 设置为 https://example.com/myapp/login.aspx 。当我登录时,它会将我重定向到 https://example.com且未指定 URL https://example.com/myapp/login.aspx

如何确保它重定向到正确的 URL?以下是启动代码。

    public void Configuration(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

app.UseCookieAuthentication(new CookieAuthenticationOptions());

app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = ConfigurationManager.AppSettings["owin:ClientId"].ToString(),
Authority = "https://login.microsoftonline.com/yz5036e3-2951-4c11-af4d-da019fa6a57d",
RedirectUri = ConfigurationManager.AppSettings["RedirectUri"].ToString()
});
}

最佳答案

如何触发登录流程?如果您遵循示例并通过调用挑战来启动登录,如 https://github.com/Azure-Samples/active-directory-dotnet-webapp-openidconnect/blob/master/WebApp-OpenIDConnect-DotNet/Controllers/AccountController.cs 中所示,您可能需要确保 AuthenticationProperties 中的 RedirectUri 指向您最终(如身份验证之后)想要登陆的 URL。我知道,这非常令人困惑 - OIDC 选项中的 RedirectUri 属性指向您想要在身份验证协议(protocol)中使用的重定向,即您想要接收身份验证 token 的重定向 - 而 AuthenticationProperties 中的属性是您想要的本地 URL在您与身份提供商的交换成功结束后重定向到。由于历史原因,这些属性具有相同的名称。

关于asp.net - Azure Active Directory 回复 URL 重定向到根,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45814679/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com