You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/active-directory/develop/howto-add-app-roles-in-azure-ad-apps.md
+6-68Lines changed: 6 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,15 +26,12 @@ Another approach is to use Azure AD Groups and Group Claims as shown in the [act
26
26
27
27
## Declare roles for an application
28
28
29
-
You define app roles by using the [Azure portal](https://portal.azure.com). App roles are usually defined on an application registration representing a service, app or API. When a user signs in to the application, Azure AD emits a `roles` claim for each role that the user or service principal has been granted individually to the user and from their group membership. This can be used to implement claim-based authorization. App roles can be assigned [to a user or a group of users](../manage-apps/add-application-portal-assign-users.md). App roles can also be assigned to the service principal for another application, or [to the service principal for a managed identity](../managed-identities-azure-resources/how-to-assign-app-role-managed-identity-powershell.md).
29
+
You define app roles by using the [Azure portal](https://portal.azure.com) during the [app registration process](quickstart-register-app.md). App roles are defined on an application registration representing a service, app or API. When a user signs in to the application, Azure AD emits a `roles` claim for each role that the user or service principal has been granted individually to the user and the user's group memberships. This can be used to implement claim-based authorization. App roles can be assigned [to a user or a group of users](../manage-apps/add-application-portal-assign-users.md). App roles can also be assigned to the service principal for another application, or [to the service principal for a managed identity](../managed-identities-azure-resources/how-to-assign-app-role-managed-identity-powershell.md).
30
30
31
31
> [!IMPORTANT]
32
32
> Currently if you add a service principal to a group, and then assign an app role to that group, Azure AD does not add the `roles` claim to tokens it issues.
33
33
34
-
There are two ways to declare app roles by using the Azure portal:
35
-
36
-
-[App roles UI](#app-roles-ui)
37
-
-[App manifest editor](#app-manifest-editor)
34
+
App roles are declared using the app roles by using[App roles UI](#app-roles-ui) in the Azure portal:
38
35
39
36
The number of roles you add counts toward application manifest limits enforced by Azure Active Directory. For information about these limits, see the [Manifest limits](./reference-app-manifest.md#manifest-limits) section of [Azure Active Directory app manifest reference](reference-app-manifest.md).
40
37
@@ -64,66 +61,6 @@ To create an app role by using the Azure portal's user interface:
64
61
65
62
1. Select **Apply** to save your changes.
66
63
67
-
### App manifest editor
68
-
69
-
To add roles by editing the manifest directly:
70
-
71
-
1. Sign in to the <ahref="https://portal.azure.com/"target="_blank">Azure portal</a>.
72
-
1. Select the **Directory + subscription** filter in top menu, and then choose the Azure Active Directory tenant that contains the app registration to which you want to add an app role.
73
-
1. Search for and select **Azure Active Directory**.
74
-
1. Under **Manage**, select **App registrations**, and then select the application you want to define app roles in.
75
-
1. Again under **Manage**, select **Manifest**.
76
-
1. Edit the app manifest by locating the `appRoles` setting and adding your application roles. You can define app roles that target `users`, `applications`, or both. The following JSON snippets show examples of both.
77
-
1. Save the manifest.
78
-
79
-
Each app role definition in the manifest must have a unique GUID for its `id` value.
80
-
81
-
The `value` property of each app role definition should exactly match the strings that are used in the code in the application. The `value` property can't contain spaces. If it does, you'll receive an error when you save the manifest.
82
-
83
-
#### Example: User app role
84
-
85
-
This example defines an app role named `Writer` that you can assign to a `User`:
86
-
87
-
```json
88
-
"appId": "8763f1c4-0000-0000-0000-158e9ef97d6a",
89
-
"appRoles": [
90
-
{
91
-
"allowedMemberTypes": [
92
-
"User"
93
-
],
94
-
"displayName": "Writer",
95
-
"id": "d1c2ade8-0000-0000-0000-6d06b947c66f",
96
-
"isEnabled": true,
97
-
"description": "Writers Have the ability to create tasks.",
98
-
"value": "Writer"
99
-
}
100
-
],
101
-
"availableToOtherTenants": false,
102
-
```
103
-
104
-
#### Example: Application app role
105
-
106
-
When available to `applications`, app roles appear as application permissions in an app registration's **Manage** section > **API permissions > Add a permission > My APIs > Choose an API > Application permissions**.
107
-
108
-
This example shows an app role targeted to an `Application`:
109
-
110
-
```json
111
-
"appId": "8763f1c4-0000-0000-0000-158e9ef97d6a",
112
-
"appRoles": [
113
-
{
114
-
"allowedMemberTypes": [
115
-
"Application"
116
-
],
117
-
"displayName": "ConsumerApps",
118
-
"id": "47fbb575-0000-0000-0000-0f7a6c30beac",
119
-
"isEnabled": true,
120
-
"description": "Consumer apps have access to the consumer data.",
121
-
"value": "Consumer"
122
-
}
123
-
],
124
-
"availableToOtherTenants": false,
125
-
```
126
-
127
64
## Assign users and groups to roles
128
65
129
66
Once you've added app roles in your application, you can assign users and groups to the roles. Assignment of users and groups to roles can be done through the portal's UI, or programmatically using [Microsoft Graph](/graph/api/user-post-approleassignments). When the users assigned to the various app roles sign in to the application, their tokens will have their assigned roles in the `roles` claim.
@@ -164,7 +101,7 @@ To assign app roles to an application by using the Azure portal:
164
101
165
102
The newly added roles should appear in your app registration's **API permissions** pane.
166
103
167
-
####Grant admin consent
104
+
### Grant admin consent
168
105
169
106
Because these are _application permissions_, not delegated permissions, an admin must grant consent to use the app roles assigned to the application.
170
107
@@ -176,7 +113,7 @@ The **Status** column should reflect that consent has been **Granted for \<tenan
176
113
<aname="use-app-roles-in-your-web-api"></a>
177
114
## Usage scenario of app roles
178
115
179
-
If you're implementing app role business logic that signs in the users in your application scenario, first define the app roles in **App registration**. Then, an admin assigns them to users and groups in the **Enterprise applications** pane. These assigned app roles are included with any token that's issued for your application, either access tokens when your app is the API being called by an app or ID tokens when your app is signing in a user.
116
+
If you're implementing app role business logic that signs in the users in your application scenario, first define the app roles in **App registration**. Then, an admin assigns them to users and groups in the **Enterprise applications** pane. These assigned app roles are included with any token that's issued for your application, either access tokens when your app is the API being called by an app or ID tokens when your app is signing in a user.
180
117
181
118
If you're implementing app role business logic in an app-calling-API scenario, you have two app registrations. One app registration is for the app, and a second app registration is for the API. In this case, define the app roles and assign them to the user or group in the app registration of the API. When the user authenticates with the app and requests an access token to call the API, a roles claim is included in the access token. Your next step is to add code to your web API to check for those roles when the API is called.
182
119
@@ -194,13 +131,14 @@ Though you can use app roles or groups for authorization, key differences betwee
194
131
195
132
Developers can use app roles to control whether a user can sign in to an app or an app can obtain an access token for a web API. To extend this security control to groups, developers and admins can also assign security groups to app roles.
196
133
197
-
App roles are preferred by developers when they want to describe and control the parameters of authorization in their app themselves. For example, an app using groups for authorization will break in the next tenant as both the group ID and name could be different. An app using app roles remains safe. In fact, assigning groups to app roles is popular with SaaS apps for the same reasons.
134
+
App roles are preferred by developers when they want to describe and control the parameters of authorization in their app themselves. For example, an app using groups for authorization will break in the next tenant as both the group ID and name could be different. An app using app roles remains safe. In fact, assigning groups to app roles is popular with SaaS apps for the very same reasons as it allows the SaaS app to be provisioned in multiple tenants.
198
135
199
136
## Next steps
200
137
201
138
Learn more about app roles with the following resources.
202
139
203
140
- Code samples on GitHub
141
+
-[Add authorization using app roles & roles claims to an ASP\.NET Core web app](https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/blob/master/5-WebApp-AuthZ/5-1-Roles/README.md)
204
142
-[Add authorization using groups and group claims to an ASP.NET Core web app](https://aka.ms/groupssample)
205
143
-[Angular single-page application (SPA) calling a .NET Core web API and using app roles and security groups](https://github.com/Azure-Samples/ms-identity-javascript-angular-tutorial/tree/main/5-AccessControl)
206
144
-[React single-page application (SPA) calling a Node.js web API and using app roles and security groups](https://github.com/Azure-Samples/ms-identity-javascript-react-tutorial/tree/main/5-AccessControl)
0 commit comments