Azure Active Directory 登录:Web 应用程序权限,未触发用户同意

Azure Active Directory Login: Web App Permissions, User Consent not triggered

我目前已经设置了一个 AAD 实例,我正在通过我的 Web 应用程序对我的用户进行身份验证,并且运行良好。

当我在 AAD 上添加和配置应用程序时,我添加了访问 Office365 日历所需的应用程序和委派权限 API。但是,唯一缺少的是在登录流程中,不会提示用户同意权限,因为我在您的文档中阅读的内容应该会发生这种情况:https://msdn.microsoft.com/en-us/library/azure/dn132599.aspx#BKMK_Consent

我不确定我错过了什么。显然,从文档中,

After the user has signed in, Azure AD will determine if the user needs to be shown a consent page. This determination is based on whether the user (or their organization’s administrator) has already granted the application consent. If consent has not already been granted, Azure AD will prompt the user for consent and will display the required permissions it needs to function. The set of permissions that is displayed in the consent dialog are the same as what was selected in the Permissions to other applications control in the Azure Management Portal.

所以也许我已经以某种方式隐式授予了管理员对这些权限的同意,但我不知道这是怎么发生的。

我已经附加了我在 AAD 应用程序上配置的权限。

如有任何帮助,我们将不胜感激。

试试这个:

What is the Resource parameter in Windows Azure AD tenant application oAuth 2.0 specification

将资源参数更改为 https://graph.windows.net 对我有用。

此外,Microsoft 支持建议禁用除 "Enable sign-on and read users' profiles" 之外的所有权限,显然是为了避免与权限相关的问题。我知道这不是您的解决方案,但至少它为您提供了一个测试用例。

如果管理员使用 AUX 门户 (manage.windowsazure.com) 在其租户中创建应用程序,并请求对其他应用程序的权限,则同一租户中的用户会预先同意该应用程序。请注意,此行为不适用于我们的其他应用程序注册门户(portal.azure.com 或 identity.microsoft.com)

我相信这就是为什么您在租户中的用户登录您的应用程序时看不到同意对话框的原因。如果您想推动同意对话体验,您可以做一些不同的事情:

  1. 您可以在登录时使用查询字符串提示"consent"或"admin_consent"。在这里查看:https://msdn.microsoft.com/en-us/library/azure/dn645542.aspx
  2. 您可以使用 AAD PowerShell 从租户中删除应用程序的服务主体。您可以在此处了解如何操作:https://msdn.microsoft.com/en-us/library/azure/dn194113.aspx
  3. 您可以让其他租户的用户尝试登录您的多租户应用程序。
  4. 您可以在非管理员帐户下创建您的应用程序。

希望对您有所帮助!

肖恩·塔布里兹