Azure AD App 应用程序权限与委派权限

Azure AD App Application Permissions vs Delegated Permissions

我正在创建一个 Azure AD 应用程序并注意到有两种权限类型,应用程序权限和委派权限。两者有什么区别,应该在什么场景下使用?

来自此处的文档:Configure a client application to access web APIs:

  • Application Permissions: Your application needs to access the web API directly as itself (no user context). This type of permission requires administrator consent and is also not available for native client applications.
  • Delegation Permissions: Your application needs to access the web API as the signed-in user, but with access limited by the selected permission. This type of permission can be granted by a user unless the permission is configured as requiring administrator consent.

基于此,如果您的应用程序需要用户模拟,那么您将需要使用委派权限。

当您想以登录用户身份调用 Web API 时,通常会使用委派权限。例如,Web API 需要根据用户身份过滤数据 returns,或者以登录用户身份执行某些操作。或者甚至只是记录发起呼叫的用户。

应用程序调用 API 时使用应用程序权限。例如获取某个邮政编码的天气预报(哪个用户登录并不重要)。当没有用户在场时,客户端甚至可以调用 API(某些后台服务调用 API 来更新某些状态)。