【问题标题】:Url Redirection in Azure Active DirectoryAzure Active Directory 中的 URL 重定向
【发布时间】:2019-12-21 10:51:15
【问题描述】:

所以我创建了一个使用 Microsoft 图形 api 的 MVC 应用程序 .net 框架。它使用 Azure 重定向 uri 进行身份验证。我有http://localhost:####,它在本地运行良好。现在我在 IIS 中发布了应用程序,需要更改重定向 URI。 Azure 只接受以 localhost 或 https 开头的内容。我在 IIS 中没有 SSL 证书来执行 https,所以我想让它与 http 一起使用。 singon url和redirect url都是http?

我已经尝试 bit.ly 重定向到 http。我什至在 azure 中注册了新应用程序并提供了一个新的登录 url 并在 webconfig 上进行了更改。但是现在它说您要查找的页面无法显示http动词的无效方法。

【问题讨论】:

  • Web 应用程序和服务的重定向 URL必须以方案 https 开头。参考这个article

标签: redirect web-config azure-active-directory microsoft-graph-api http-redirect


【解决方案1】:

即使不是,您也可以将用于身份验证的 Azure 重定向 uri 设置为“https://yourdomain.com”。然后在您的应用程序中启动:

if (environment.production) {
      if (location.protocol === 'https:') {
        window.location.href = location.href.replace('https', 'http');
      }
    }

这适用于我的 Angular SPA 应用程序

【讨论】:

    【解决方案2】:

    是的。 Azure AD 有Restrictions on redirect URLs

    如果您没有 SSL 证书,最好为 https 域创建自签名证书。

    您可以参考之前的帖子:Trust a self signed cert from IIS

    【讨论】:

    • 我将自签名证书添加到 azure 门户,但现在错误为“IDX10311:RequireNonce 为 'true'(默认)但 validationContext.Nonce 为空。无法验证随机数。如果你不这样做”不需要检查 nonce,将 OpenIdConnectProtocolValidator.RequireNonce 设置为 'false'。
    • 这应该是另一个问题。此问题及其可能的解决方案已在此线程stackoverflow.com/questions/39412570/… 中进行了讨论。顺便说一句,您是否修改了 Azure 活动目录中的回复 URL?
    • 感谢您的提示响应,但看起来我可以使重定向 uri 工作的唯一方法是为已发布的应用程序获取合法的 SSL 证书。自分配证书无效。 Azure 会知道 url 不是合法的证书 URL。一旦我用合法的 SSL 证书完成这个过程,我会回来的。
    • 是的,自分配证书用于测试目的。如果应用程序在生产环境中运行,则应由受信任的证书颁发机构签名。了解更多详情:docs.microsoft.com/en-us/azure/app-service/…
    • 我仍在等待我的系统管理员为我提供证书,截至目前,我在 azure 广告上有 localhost 用于重定向。 @艾伦吴
    猜你喜欢
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 2020-02-07
    • 2015-05-06
    • 1970-01-01
    • 2014-02-08
    • 2015-04-10
    • 2018-10-14
    相关资源
    最近更新 更多