azure - 如何让 Azure OIDC 尊重我的重定向 URI?

标签 azure asp.net-core azure-active-directory openid-connect

我有一个应用托管在 Azure PaaS 上,使用 Open ID Connect 进行身份验证。

应用程序 URL 类似于:https://env.app.entity.my.domain
Azure ASE 是:https://entity-app-env-web.webenvase.my.domain

只要我为 https://entity-app-env-web.webenvase.my.domain/signin-oidc 配置重定向 URI在 Azure 中,它可以工作。这是因为它忽略了我设置中的重定向 URI。但这不是我想要的。显然,我希望将用户返回到应用程序的 URL。

无论我为 RedirectUriCallbackPath 设置什么值,它都默认为 ASE URL。我该如何解决这个问题?

appsettings.json:

"AzureAd": {
  "Instance": "https://login.microsoftonline.com/",
  "Issuer": "https://sts.windows.net/<tenant id>/",
  "Domain": "my.azure.domain",
  "TenantId": "<tenant id>",
  "ClientId": "<client id>",
  "RedirectUri": "https://env.app.entity.my.domain/signin-oidc"
}

Startup.cs(身份验证配置):

services.AddMicrosoftIdentityWebAppAuthentication(Configuration);
services.AddControllersWithViews(options =>
{
    var policy = new AuthorizationPolicyBuilder()
        .RequireAuthenticatedUser()
        .RequireRole(Role.Administrator)
        .Build();
    options.Filters.Add(new AuthorizeFilter(policy));
})
.AddMicrosoftIdentityUI();

最佳答案

我从这个answer找到在其他地方,重定向 uri 是自动计算的,不使用配置中的值。在某些情况下会使用配置中的配置,但不会用于对 Azure 的身份验证调用。

经过一段时间的摸索之后,我们的服务器团队开始删除 f5 上的规则,我们发现我们其他应用程序常见的 header 重写规则就是问题所在。具体来说,它导致身份验证 cookie 在重定向期间被拒绝并在浏览器中被删除。

我们删除了规则,一切又恢复正常。

关于azure - 如何让 Azure OIDC 尊重我的重定向 URI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67084004/

相关文章:

c# - 带有 FileInfo 的 ASP.NET Core 序列化对象返回不完整的 JSON

c# - 是否可以在仅具有公共(public)链接的容器中列出 Azure Blob?

c# - ASP.NET Core 路由前缀

c# - 如何最好地在 ASP.NET Core 中实现 Google 社交登录身份验证?

.net - 将 UPN 分配给 Azure Active Directory 应用程序注册

azure - 是否可以更改 Azure SQL 实例进行身份验证所依据的 Azure AD?

javascript - 如何为 SharePoint 网站上部署的聊天机器人配置 SSO?

azure - 创建以服务主体作为成员的 Azure AD 动态组

azure - 无法在 Azure Blob 存储中查看上传的文件

Azure B2C不使用webview