简体   繁体   English

设置提示=同意后,Azure Active Directory 需要管理员批准

[英]Azure Active Directory needs Admin Approval after setting prompt =consent

In my application in Azure Active Directory I have added one of the Admin's consent required permission to the Graph API, let say Group.Read.All .在 Azure Active Directory 中的应用程序中,我向 Graph API 添加了管理员同意所需的权限之一,例如Group.Read.All I've clicked Grant Admin Consent for ... .我点击了Grant Admin Consent for ... If I hit /authorize endpoint as a User with the query parameter prompt=consent , I'll get the view that I need admin approval.如果我使用查询参数prompt=consent作为用户点击/authorize端点,我将获得需要管理员批准的视图。 If I hit the endpoint without any prompt parameter, everything works fine - I'm able to get a token with a proper scope.如果我在没有任何prompt参数的情况下点击端点,一切正常 - 我能够获得具有适当范围的令牌。 In the documentation I've read that prompt parameter determines only the visibility of the consent.在我读过的文档中, prompt参数仅确定同意的可见性。 Why it works like that?为什么它会这样?

Regarding prompt=consent , OpenID Connect says :关于prompt=consentOpenID Connect 说

The Authorization Server SHOULD prompt the End-User for consent before returning information to the Client.授权服务器应该在将信息返回给客户端之前提示最终用户同意。 If it cannot obtain consent, it MUST return an error, typically consent_required .如果它不能获得同意,它必须返回一个错误,通常是consent_required

In the Microsoft Identity platform, this means that the end user will be required to provide consent, even if consent has been granted previously by the user or (in the case of work or school accounts, by an administrator on behalf of the user).在 Microsoft Identity 平台中,这意味着最终用户将需要提供同意,即使用户之前已授予同意或(在工作或学校帐户的情况下,由管理员代表用户)。

If the user is not authorized to consent to the requested permissions (eg because user consent is disabled or restricted), using prompt=consent will always result in a hard block for the user.如果用户未被授权同意所请求的权限(例如,因为用户同意被禁用或限制),使用prompt=consent将始终导致用户的硬阻止。

In most cases, using prompt=consent is not the best approach.在大多数情况下,使用prompt=consent并不是最好的方法。 There are typically three scenarios prompt=consent is considered:通常会考虑三种情况prompt=consent

  1. You've changed the required permissions .您已更改所需的权限 The required permissions have changed (eg permissions have been added or removed), and the user needs to consent to the new set of permissions.所需的权限已更改(例如,权限已添加或删除),并且用户需要同意新的权限集。
  2. You want to inform the user .你要通知用户 The app developer wishes to ensure the user is informed of which permissions the app will be authorized to exercise (even if an administrator has already consented on behalf of the user in question).应用程序开发人员希望确保通知用户该应用程序将有权行使哪些权限(即使管理员已代表相关用户同意)。
  3. You require consent from the user themselves, not an admin .您需要用户本人的同意,而不是管理员的同意 The app developer wishes to ensure the end-user themselves provides consent, independent of what an administrator may have authorized previously.应用程序开发人员希望确保最终用户自己提供同意,而与管理员之前可能已授权的内容无关。

If you've changed which permissions are required如果您更改了所需的权限

When the requested permissions are defined dynamically动态定义请求的权限时

On the v2.0 endpoint , the scope parameter can be used to dynamically request a list of delegated permissions.v2.0 端点上scope参数可用于动态请求委托权限列表。 For example, to request the read and export delegated permissions of the API identified by https://api.example.com :例如,请求https://api.example.com标识的 API 的readexport委托权限:

scope=openid https://api.example.com/read

Azure AD will ensure that all the requested permissions have been granted, and attempt to prompt for consent for any permissions which have not yet been granted (and only for those). Azure AD 将确保已授予所有请求的权限,并尝试提示同意尚未授予的任何权限(并且仅授予这些权限)。 If the requested permissions have all been granted, the issued token will include all granted permissions (even if they were not specifically requested).如果请求的权限已全部授予,则颁发的令牌将包括所有授予的权限(即使它们没有被特别请求)。

Generally speaking, when making use of the incremental consent capability of the v2.0 endpoint, prompt=consent should not be used.一般来说,利用2.0版端点的增量同意能力的时候, prompt=consent不得使用。 Azure AD will take care of prompting for incremental consent if needed.如果需要,Azure AD 将负责提示增量同意。

When the requested permissions are defined statically当请求的权限被静态定义时

An app can also identify only the resource (ie the API) for which it is requesting an access token, the specific permissions being defined statically for the app.应用程序还可以仅识别其请求访问令牌的资源(即 API),应用程序静态定义特定权限。 Using the v2.0 endpoint, this is done in the scope parameter, making use of the special .default permission value :使用 v2.0 端点,这是在scope参数中完成的,利用特殊的.default权限值

scope=openid https://api.example.com/.default

In the v1.0 endpoint , this was achieved using the resource parameter:v1.0 端点中,这是使用resource参数实现的:

resource=https://api.example.com

The list of required permissions is configured in a static list on the app registration.所需权限列表在应用程序注册的静态列表中配置。 In the Azure portal, this list is under Configured permissions in Azure AD > App registrations > API permissions.在 Azure 门户中,此列表位于 Azure AD > 应用注册 > API 权限中的已配置权限下。 In the unerlying Application entity in Microsoft Graph (and in the app manifest ), this is stoerd in the requiredResourceAccess property.在 Microsoft Graph(和应用程序清单)中的底层Application实体中,这在requiredResourceAccess属性中。

On receiving a request of this type (on either the v1 or v2 endpoint), Azure AD will check which permissions have been granted for the requested resource:收到此类请求后(在 v1 或 v2 终结点上),Azure AD 将检查已为请求的资源授予哪些权限:

  1. If no delegated permissions have been granted for the requested resource OR if prompt=consent is used, Azure AD will attempt to prompt for all the required permissions from the statically-defined list.如果没有为请求的资源授予委派权限,或者使用prompt=consent ,Azure AD 将尝试从静态定义的列表中提示所有必需的权限。 This will include permissions for other APIs, if any are configured.这将包括其他 API 的权限(如果有)。
  2. If any delegated permission has been granted for the requested resource, Azure AD will issue the token with all granted permissions.如果已为请求的资源授予任何委派权限,Azure AD 将颁发具有所有授予权限的令牌。 The scopes parameter of the response will include the list of permissions included in the access token.响应scopes参数将包括访问令牌中包含的权限列表。

Applications relying on statically-defined required permissions (ie /.default on v2 or resource on v1) should not use prompt=consent for every sign-in request.应用程序依赖于静态定义的权限(即/.default在v2或resource上的V1)应该使用prompt=consent为每个登录请求。 Instead, the application should:相反,应用程序应该:

  1. Perform a sign in without prompt=consent .没有prompt=consent执行登录。
  2. Check the scope parameter of the response :检查响应scope参数:
    • If the desired permissions are listed, no further action is necessary.如果列出了所需的权限,则无需进一步操作。
    • If not (eg if a new permission was added to the list of required permissions after the user initially consented to the app), only then should the user be sent back again, this time with prompt=consent .如果没有(例如,如果在用户最初同意应用程序后将新权限添加到所需权限列表中),则只有这样,用户才能再次被发送回,这次使用prompt=consent

This strategy ensures that users can sign in to an app when an administrator has consented on their behalf (eg because they aren't authorized to consent on their own), and only forces the consent prompt (or an escalation to an admin to consent on their behalf) when a new permission has been configured.此策略确保用户可以在管理员代表他们同意时登录应用程序(例如,因为他们无权自行同意),并且仅强制同意提示(或升级到管理员同意)代表他们)配置新权限时。

If you want to inform the user如果您想通知用户

Using prompt=consent is not a good approach if the goal is to only inform the user of which permissions the application has been authorized to exercise (either by the user previously, or by an administrator on the user's behalf).如果目标只是通知用户应用程序已被授权行使哪些权限(由用户先前授权,或由代表用户的管理员授权),则使用prompt=consent不是一个好方法。

Instead, an application can use the scope parameter of the token response to construct the desired interrupt experience (eg after the user has been redirected back to the app and the token has been retrieved, but before continuing), informing the user of which permissions it has been granted.相反,应用程序可以使用令牌响应的scope参数来构建所需的中断体验(例如,在用户被重定向回应用程序并检索到令牌之后,但在继续之前),通知用户它的权限已被授予。

If you require consent by the user, not an admin如果您需要用户而非管理员的同意

There may exist very specific cases when an application requires user consent for the requested permissions, and wishes to not accept consent granted on behalf of the user by an administrator.当应用程序要求用户同意所请求的权限,但希望接受管理员代表用户授予的同意时,可能存在非常特殊的情况。

In this case, using prompt=consent in all sign-ins could be used, but there are important caveats to consider:在这种情况下,可以在所有登录中使用prompt=consent ,但有一些重要的警告需要考虑:

  • In many organizations, user consent is disabled or restricted.在许多组织中, 用户同意被禁用或限制。 If users are not authorized to consent to the permissions configured for your app, they will not be able to use your application.如果用户无权同意为您的应用配置的权限,他们将无法使用您的应用。
  • The user will be prompted for consent every single sign-in, even if the user themselves already previously granted consent.每次登录都会提示用户同意,即使用户自己之前已经同意。
  • Since this is a query parameter, a knowledgeable user could very easily intercept the request before it is made, and remove prompt=consent (and if consent was already previously granted, they will not be prompted for consent).由于这是一个查询参数,知识渊博的用户可以很容易地在请求发出之前拦截它,并删除prompt=consent (如果之前已经授予同意,则不会提示他们同意)。

In this case, it may be better the app to implement a separate consent-granting experience after the user has signed in (similar to the "inform" scenario described earlier), separating the app's additional consent requirements from the consent experience provided by the Microsoft identity platform.在这种情况下,应用在用户登录实现单独的同意授予体验可能更好(类似于前面描述的“通知”场景),将应用的附加同意要求与 Microsoft 提供的同意体验分开身份平台。

prompt=consent triggers the OAuth consent dialog after the user signs in, asking the user to grant permissions to the app. prompt=consent在用户登录后触发 OAuth 同意对话框,要求用户授予应用程序权限。

Individuals accessing an app that requires at least one permission that is outside their scope of authority.访问至少需要一项超出其权限范围的权限的应用程序的个人。

Admins will see the same prompt show the permission and will see an additional control on the traditional consent prompt that will allow them consent on behalf of the entire tenant.管理员将看到显示权限的相同提示,并将看到对传统同意提示的额外控制,这将允许他们代表整个租户同意。

在此处输入图片说明

Users will be blocked from granting consent to the application, and they will be told to ask their admin for access to the app.用户将无法同意该应用程序,并且他们将被告知要求他们的管理员访问该应用程序。

在此处输入图片说明

For more details, you could refer to this article .更多细节,你可以参考这篇文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在开发期间同意 Azure Active Directory 企业应用程序进行多租户登录而无需发布者批准? - How to consent to an Azure Active Directory Enterprise App for Multi-Tenant Login without Publisher Approval during development? Azure Active Directory同意缓存吗? - Is Azure Active Directory Consent Cached? 为什么用户添加到用户列表后需要在 Azure 单一登录中请求管理员批准? - Why the user needs to request admin approval in Azure Single Sign On after he is added to users list? .Net Core MVC 应用与 IdentityServer4,使用 Azure Active Directory 登录。 管理员同意和权限问题 - .Net Core MVC app with IdentityServer4, login with Azure Active Directory. Problem with admin consent and permissions 从 Azure Active Directory 撤销管理员同意时通知客户端应用程序 - Notify client app when admin consent is revoked from Azure Active Directory Active Directory中的管理员同意 - Administrator Consent in Active Directory Azure 活动目录双重同意,非确定性流 - Azure active directory double consent, non-deterministic flow Azure Active Directory登录:Web应用程序权限,未触发用户同意 - Azure Active Directory Login: Web App Permissions, User Consent not triggered 在 Azure 中授予管理员同意 - Grant Admin Consent in Azure Azure AAD 需要管理员批准 - Azure AAD Need admin approval
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM