查看向企业应用程序授予的权限 - Microsoft Entra ID

查看向企业应用程序授予的权限 - Microsoft Entra ID

本文介绍如何查看授予 Microsoft Entra 租户中应用程序的权限。 检测到恶意应用程序或应用程序拥有的权限超过必要权限时,可能需要查看权限。 了解如何使用 Microsoft Graph API 和现有 PowerShell 版本撤销向应用程序授予的权限。

本文中的步骤适用于通过用户或管理员同意添加到 Microsoft Entra 租户的所有应用程序。 有关同意应用程序的详细信息,请参阅用户和管理员同意。

先决条件

要查看向应用程序授予的权限,需满足以下条件:

一个具有活动订阅的 Microsoft Entra 帐户。 免费创建帐户。

以下角色之一:

云应用程序管理员

应用程序管理员。

不是管理员的服务主体所有者能够使刷新令牌无效。

在 Microsoft Entra 管理中心中查看与撤销权限

可以访问 Microsoft Entra 管理中心来查看授予应用的权限。 可以撤销管理员为整个组织授予的权限,并且可以获取上下文 PowerShell 脚本来执行其他操作。

有关如何还原已撤销或删除的权限的信息,请参阅还原授予应用程序的权限。

若要查看已授予整个组织或特定用户或组的应用程序权限,请执行以下操作:

至少以云应用程序管理员身份登录到 Microsoft Entra 管理中心。

请导航到 Entra ID>企业应用程序>所有应用程序。

选择想要限制访问的应用程序。

选择“权限”。

若要查看适用于整个组织的权限,请选择“管理员同意”选项卡。若要查看授予特定用户或组的权限,请选择“用户同意”选项卡。

若要查看给定权限的详细信息,请从列表中选择权限。 “权限详细信息”窗格随即打开。

查看向应用程序授予的权限后,可以撤销管理员为整个组织授予的权限。

注意

不能通过门户在“用户同意”选项卡中撤销权限。 可以使用 Microsoft Graph API 调用或 PowerShell cmdlet 撤销这些权限。 有关详细信息,请转到本文的 PowerShell 和 Microsoft Graph 选项卡。

若要在“管理员同意”选项卡中撤销权限,请执行以下操作:

在“管理员同意”选项卡中查看权限列表。

选择要撤销的权限,然后选择该权限的 ... 控件。

选择“撤销权限”。

使用 Microsoft Entra PowerShell 查看和撤销权限

使用以下Microsoft Entra PowerShell 脚本撤销授予应用程序的所有权限。 至少需要云应用程序管理员登录。

Connect-Entra -scopes "Application.ReadWrite.All", "DelegatedPermissionGrant.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"

# Get Service Principal using objectId

$app_name = ""

$sp = Get-EntraServicePrincipal -Filter "displayName eq '$app_name'"

# Get all delegated permissions for the service principal

$spOAuth2PermissionsGrants = Get-EntraOAuth2PermissionGrant -All | Where-Object { $_.clientId -eq $sp.ObjectId }

# Remove all delegated permissions granted to the service principal

$spOAuth2PermissionsGrants | ForEach-Object {

Remove-EntraOAuth2PermissionGrant -ObjectId $_.ObjectId

}

# Get all application permissions for the service principal

$spApplicationPermissions = Get-EntraServicePrincipalAppRoleAssignment -ObjectId $sp.ObjectId -All | Where-Object { $_.PrincipalType -eq "ServicePrincipal" }

# Remove all application permissions

$spApplicationPermissions | ForEach-Object {

Remove-EntraServicePrincipalAppRoleAssignment -ObjectId $_.PrincipalId -AppRoleAssignmentId $_.objectId

}

使用 Microsoft Entra PowerShell 删除所有用户和组分配

使用以下脚本从应用程序中移除用户或组的 appRoleAssignments。

connect-entra -scopes "Application.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"

#Retrieve the service principal object ID.

$app_name = ""

$sp = Get-EntraServicePrincipal -Filter "displayName eq '$app_name'"

$sp.ObjectId

# Get Microsoft Entra App role assignments using objectId of the Service Principal

$assignments = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId $sp.ObjectId -All $true

# Remove all users and groups assigned to the application

$assignments | ForEach-Object {

if ($_.PrincipalType -eq "User") {

Remove-EntraUserAppRoleAssignment -ObjectId $_.PrincipalId -AppRoleAssignmentId $_.ObjectId

} elseif ($_.PrincipalType -eq "Group") {

Remove-EntraGroupAppRoleAssignment -ObjectId $_.PrincipalId -AppRoleAssignmentId $_.ObjectId

}

}

使用 Microsoft Graph PowerShell 查看与撤销权限

使用以下 Microsoft Graph PowerShell 脚本可撤销向应用程序授予的所有权限。 至少需要云应用程序管理员登录。

Connect-MgGraph -Scopes "Application.ReadWrite.All", "Directory.ReadWrite.All", "DelegatedPermissionGrant.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"

# Get Service Principal using objectId

$sp = Get-MgServicePrincipal -ServicePrincipalID ""

Example: Get-MgServicePrincipal -ServicePrincipalId 'aaaaaaaa-bbbb-cccc-1111-222222222222'

# Get all delegated permissions for the service principal

$spOAuth2PermissionsGrants= Get-MgOauth2PermissionGrant -All| Where-Object { $_.clientId -eq $sp.Id }

# Remove all delegated permissions

$spOauth2PermissionsGrants |ForEach-Object {

Remove-MgOauth2PermissionGrant -OAuth2PermissionGrantId $_.Id

}

# Get all application permissions for the service principal

$spApplicationPermissions = Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $Sp.Id -All | Where-Object { $_.PrincipalType -eq "ServicePrincipal" }

# Remove all application permissions

$spApplicationPermissions | ForEach-Object {

Remove-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $Sp.Id -AppRoleAssignmentId $_.Id

}

使用 Microsoft Graph PowerShell 删除所有用户和组分配

使用以下脚本从应用程序中移除用户或组的 appRoleAssignments。

Connect-MgGraph -Scopes "Application.ReadWrite.All", "Directory.ReadWrite.All", "AppRoleAssignment.ReadWrite.All"

# Get Service Principal using objectId

$sp = Get-MgServicePrincipal -ServicePrincipalID ""

Example: Get-MgServicePrincipal -ServicePrincipalId 'aaaaaaaa-bbbb-cccc-1111-222222222222'

# Get Microsoft Entra App role assignments using objectID of the Service Principal

$spApplicationPermissions = Get-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalID $sp.Id -All | Where-Object { $_.PrincipalType -eq "ServicePrincipal" }

# Revoke refresh token for all users assigned to the application

$spApplicationPermissions | ForEach-Object {

Remove-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $_.PrincipalId -AppRoleAssignmentId $_.Id

}

使用 Microsoft Graph 查看和撤销权限

若要查看权限,请至少以云应用程序管理员身份登录到 Graph 浏览器。

你需要同意以下权限:

Application.ReadWrite.All、Directory.ReadWrite.All、DelegatedPermissionGrant.ReadWrite.All、AppRoleAssignment.ReadWrite.All。

委托的权限

运行以下查询,查看授予应用程序的委托的权限。

使用对象 ID 获取服务主体

GET https://graph.microsoft.com/v1.0/servicePrincipals/{id}

示例:

GET https://graph.microsoft.com/v1.0/servicePrincipals/00001111-aaaa-2222-bbbb-3333cccc4444

获取服务主体的所有委托的权限

GET https://graph.microsoft.com/v1.0/servicePrincipals/{id}/oauth2PermissionGrants

使用 oAuth2PermissionGrants ID 删除委托的权限。

DELETE https://graph.microsoft.com/v1.0/oAuth2PermissionGrants/{id}

应用程序权限

运行以下查询,查看授予应用程序的应用程序权限。

获取服务主体的所有应用程序权限

GET https://graph.microsoft.com/v1.0/servicePrincipals/{servicePrincipal-id}/appRoleAssignments

使用 appRoleAssignment ID 删除应用程序权限

DELETE https://graph.microsoft.com/v1.0/servicePrincipals/{resource-servicePrincipal-id}/appRoleAssignedTo/{appRoleAssignment-id}

使用 Microsoft Graph 删除所有用户和组分配

运行以下查询,移除应用程序的用户或组的 appRoleAssignments。

使用 objectID 获取服务主体。

GET https://graph.microsoft.com/v1.0/servicePrincipals/{id}

示例:

GET https://graph.microsoft.com/v1.0/servicePrincipals/aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb

使用服务主体的 objectID 获取 Microsoft Entra 应用角色分配。

GET https://graph.microsoft.com/v1.0/servicePrincipals/{servicePrincipal-id}/appRoleAssignedTo

使用 appRoleAssignment ID 撤销分配给应用程序的用户和组的刷新令牌。

DELETE https://graph.microsoft.com/v1.0/servicePrincipals/{servicePrincipal-id}/appRoleAssignedTo/{appRoleAssignment-id}

注意

撤销当前授予的权限不会阻止用户重新同意应用程序请求的权限。 需要阻止应用程序通过动态许可请求权限。 如果要完全阻止用户同意,请阅读配置用户同意应用程序的方式。

要考虑的其他授权

委托的权限和应用程序权限并不是授予应用程序和用户对受保护资源的访问权限的唯一方法。 管理员应了解可能允许访问敏感信息的其他授权系统。 Microsoft 各种授权系统的示例包括 Microsoft Entra 内置角色、Exchange RBAC 和 Teams 资源特定的同意。

相关内容

配置用户同意设置

配置管理员同意工作流

还原撤销的权限

相关推荐

靈堂小知識
在哪个应用商店能下载365

靈堂小知識

📅 08-03 👍 653
锂电池能用多久?寿命有何限制?
365bet返水多少

锂电池能用多久?寿命有何限制?

📅 07-27 👍 833
DNF FPS提升技巧
365平台客服电话

DNF FPS提升技巧

📅 07-07 👍 484
热水器接地线怎么安装 正确地安装和使用热水器接地线【详解】
输得不冤——斯巴鲁力狮试驾体验兼谈斯巴鲁在中国市场的低迷
侯門深似海
365bet返水多少

侯門深似海

📅 08-17 👍 554