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
To view or edit the claims issued in the JWT to the application, open the application in Azure portal. Then select **Single sign-on** blade in the left-hand menu and open the **Attributes & Claims** section.
27
+
To view or edit the claims issued in the JWT to the application:
28
28
29
-
:::image type="content" source="./media/jwt-claims-customization/attributes-claims.png" alt-text="Screenshot of opening the Attributes & Claims section in the Azure portal.":::
29
+
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least a [Cloud Application Administrator](../roles/permissions-reference.md#cloud-application-administrator).
1. Select the application, select **Single sign-on** in the left-hand menu, and then select **Edit** in the **Attributes & Claims** section.
30
32
31
33
An application may need claims customization for various reasons. For example, when an application requires a different set of claim URIs or claim values. Using the **Attributes & Claims** section, you can add or remove a claim for your application. You can also create a custom claim that is specific for an application based on the use case.
32
34
33
35
The following steps describe how to assign a constant value:
34
36
35
-
1. Sign in to the [Azure portal](https://portal.azure.com).
36
-
1. In the **Attributes & Claims** section, Select **Edit** to edit the claims.
37
-
1. Select the required claim that you want to modify.
37
+
1. Select the claim that you want to modify.
38
38
1. Enter the constant value without quotes in the **Source attribute** as per your organization, and then select **Save**.
39
39
40
-
:::image type="content" source="./media/jwt-claims-customization/customize-claim.png" alt-text="Screenshot of customizing a claim in the Azure portal.":::
41
-
42
40
The Attributes overview displays the constant value.
43
41
44
-
:::image type="content" source="./media/jwt-claims-customization/claims-overview.png" alt-text="Screenshot of displaying claims in the Azure portal.":::
45
-
46
42
## Special claims transformations
47
43
48
44
You can use the following special claims transformations functions.
@@ -70,8 +66,6 @@ To apply a transformation to a user attribute:
70
66
1.**Treat source as multivalued** indicates whether the transform is applied to all values or just the first. By default, the first element in a multi-value claim is applied the transformations. When you check this box, it ensures it's applied to all. This checkbox is only enabled for multi-valued attributes. For example, `user.proxyaddresses`.
71
67
1. To apply multiple transformations, select **Add transformation**. You can apply a maximum of two transformations to a claim. For example, you could first extract the email prefix of the `user.mail`. Then, make the string upper case.
72
68
73
-
:::image type="content" source="./media/jwt-claims-customization/sso-saml-multiple-claims-transformation.png" alt-text="Screenshot of claims transformation.":::
74
-
75
69
You can use the following functions to transform claims.
76
70
77
71
| Function | Description |
@@ -81,8 +75,8 @@ You can use the following functions to transform claims.
81
75
|**ToLowercase()**| Converts the characters of the selected attribute into lowercase characters. |
82
76
|**ToUppercase()**| Converts the characters of the selected attribute into uppercase characters. |
83
77
|**Contains()**| Outputs an attribute or constant if the input matches the specified value. Otherwise, you can specify another output if there's no match. <br/>For example, if you want to emit a claim where the value is the user's email address if it contains the domain `@contoso.com`, otherwise you want to output the user principal name. To perform this function, you configure the following values:<br/>*Parameter 1(input)*: user.email<br/>*Value*: "@contoso.com"<br/>Parameter 2 (output): user.email<br/>Parameter 3 (output if there's no match): user.userprincipalname |
84
-
|**EndWith()**| Outputs an attribute or constant if the input ends with the specified value. Otherwise, you can specify another output if there's no match.<br/>For example, if you want to emit a claim where the value is the user's employee ID if the employee ID ends with "000", otherwise you want to output an extension attribute. To perform this function, you configure the following values:<br/>*Parameter 1(input)*: user.employeeid<br/>*Value*: "000"<br/>Parameter 2 (output): user.employeeid<br/>Parameter 3 (output if there's no match): user.extensionattribute1 |
85
-
|**StartWith()**| Outputs an attribute or constant if the input starts with the specified value. Otherwise, you can specify another output if there's no match.<br/>For example, if you want to emit a claim where the value is the user's employee ID if the country/region starts with "US", otherwise you want to output an extension attribute. To perform this function, you configure the following values:<br/>*Parameter 1(input)*: user.country<br/>*Value*: "US"<br/>Parameter 2 (output): user.employeeid<br/>Parameter 3 (output if there's no match): user.extensionattribute1 |
78
+
|**EndWith()**| Outputs an attribute or constant if the input ends with the specified value. Otherwise, you can specify another output if there's no match.<br/>For example, if you want to emit a claim where the value is the user's employee ID if the employee ID ends with `000`, otherwise you want to output an extension attribute. To perform this function, you configure the following values:<br/>*Parameter 1(input)*: user.employeeid<br/>*Value*: "000"<br/>Parameter 2 (output): user.employeeid<br/>Parameter 3 (output if there's no match): user.extensionattribute1 |
79
+
|**StartWith()**| Outputs an attribute or constant if the input starts with the specified value. Otherwise, you can specify another output if there's no match.<br/>For example, if you want to emit a claim where the value is the user's employee ID if the country/region starts with `US`, otherwise you want to output an extension attribute. To perform this function, you configure the following values:<br/>*Parameter 1(input)*: user.country<br/>*Value*: "US"<br/>Parameter 2 (output): user.employeeid<br/>Parameter 3 (output if there's no match): user.extensionattribute1 |
86
80
|**Extract() - After matching**| Returns the substring after it matches the specified value.<br/>For example, if the input's value is `Finance_BSimon`, the matching value is `Finance_`, then the claim's output is `BSimon`. |
87
81
|**Extract() - Before matching**| Returns the substring until it matches the specified value.<br/>For example, if the input's value is `BSimon_US`, the matching value is `_US`, then the claim's output is `BSimon`. |
88
82
|**Extract() - Between matching**| Returns the substring until it matches the specified value.<br/>For example, if the input's value is `Finance_BSimon_US`, the first matching value is `Finance_`, the second matching value is `_US`, then the claim's output is `BSimon`. |
@@ -187,24 +181,20 @@ For example, Britta Simon is a guest user in the Contoso tenant. Britta belongs
187
181
188
182
First, the Microsoft identity platform verifies whether Britta's user type is **All guests**. Because the type is **All guests**, the Microsoft identity platform assigns the source for the claim to `user.extensionattribute1`. Second, the Microsoft identity platform verifies whether Britta's user type is **AAD guests**. Because the type is **All guests**, the Microsoft identity platform assigns the source for the claim to `user.mail`. Finally, the claim is emitted with a value of `user.mail` for Britta.
189
183
190
-
:::image type="content" source="./media/jwt-claims-customization/sso-saml-user-conditional-claims.png" alt-text="Screenshot of claims conditional configuration.":::
191
-
192
184
As another example, consider when Britta Simon tries to sign in using the following configuration. Azure AD first evaluates all conditions with source `Attribute`. The source for the claim is `user.mail` when Britta's user type is **AAD guests**. Next, Azure AD evaluates the transformations. Because Britta is a guest, `user.extensionattribute1` is the new source for the claim. Because Britta is in **AAD guests**, `user.othermail` is the new source for this claim. Finally, the claim is emitted with a value of `user.othermail` for Britta.
193
185
194
-
:::image type="content" source="./media/jwt-claims-customization/sso-saml-user-conditional-claims-2.png" alt-text="Screenshot of more claims conditional configuration.":::
195
-
196
186
As a final example, consider what happens if Britta has no `user.othermail` configured or it's empty. The claim falls back to `user.extensionattribute1` ignoring the condition entry in both cases.
197
187
198
188
## Security considerations
199
-
Applications that receive tokens rely on claim values that are authoritatively issued by Azure AD and can't be tampered with. When you modify the token contents through claims customization, these assumptions may no longer be correct. Applications must explicitly acknowledge that tokens have been modified by the creator of the customization to protect themselves from customizations created by malicious actors. This can be done in one the following ways:
189
+
Applications that receive tokens rely on claim values that can't be tampered with. When you modify the token contents through claims customization, these assumptions may no longer be correct. Applications must explicitly acknowledge that tokens have been modified to protect themselves from customizations created by malicious actors. Protect from inappropriate customizations in one the following ways:
200
190
201
191
-[Configure a custom signing key](#configure-a-custom-signing-key)
202
192
-[update the application manifest to accept mapped claims](#update-the-application-manifest).
203
193
204
194
Without this, Azure AD returns an [AADSTS50146 error code](./reference-error-codes.md#aadsts-error-codes).
205
195
206
196
## Configure a custom signing key
207
-
For multi-tenant apps, a custom signing key should be used. Don't set `acceptMappedClaims` in the app manifest. when setting up an app in the Azure portal, you get an app registration object and a service principal in your tenant. That app is using the Azure global sign-in key, which can't be used for customizing claims in tokens. To get custom claims in tokens, create a custom sign-in key from a certificate and add it to service principal. For testing purposes, you can use a self-signed certificate. After configuring the custom signing key, your application code needs to validate the token signing key.
197
+
For multi-tenant apps, a custom signing key should be used. Don't set `acceptMappedClaims` in the app manifest. when setting up an app in the Azure portal, you get an app registration object and a service principal in your tenant. That app is using the Azure global sign-in key, which can't be used for customizing claims in tokens. To get custom claims in tokens, create a custom sign-in key from a certificate and add it to service principal. For testing purposes, you can use a self-signed certificate. After you configure the custom signing key, your application code needs to validate the token signing key.
208
198
209
199
Add the following information to the service principal:
210
200
@@ -215,7 +205,7 @@ Add the following information to the service principal:
215
205
Extract the private and public key base-64 encoded from the PFX file export of your certificate. Make sure that the `keyId` for the `keyCredential` used for "Sign" matches the `keyId` of the `passwordCredential`. You can generate the `customkeyIdentifier` by getting the hash of the cert's thumbprint.
216
206
217
207
## Request
218
-
The following example shows the format of the HTTP PATCH request to add a custom signing key to a service principal. The "key" value in the `keyCredentials` property is shortened for readability. The value is base-64 encoded. For the private key, the property usage is "Sign". For the public key, the property usage is "Verify".
208
+
The following example shows the format of the HTTP PATCH request to add a custom signing key to a service principal. The "key" value in the `keyCredentials` property is shortened for readability. The value is base-64 encoded. For the private key, the property usage is `Sign`. For the public key, the property usage is `Verify`.
## Configure a custom signing key using PowerShell
263
-
Use PowerShell to [instantiate an MSAL Public Client Application](msal-net-initializing-client-applications.md#initializing-a-public-client-application-from-code) and use the [Authorization Code Grant](v2-oauth2-auth-code-flow.md) flow to obtain a delegated permission access token for Microsoft Graph. Use the access token to call Microsoft Graph and configure a custom signing key for the service principal. After configuring the custom signing key, your application code needs to [validate the token signing key](#validate-token-signing-key).
253
+
Use PowerShell to [instantiate an MSAL Public Client Application](msal-net-initializing-client-applications.md#initializing-a-public-client-application-from-code) and use the [Authorization Code Grant](v2-oauth2-auth-code-flow.md) flow to obtain a delegated permission access token for Microsoft Graph. Use the access token to call Microsoft Graph and configure a custom signing key for the service principal. After you configure the custom signing key, your application code needs to [validate the token signing key](#validate-token-signing-key).
264
254
265
-
To run this script you need:
255
+
To run this script, you need:
266
256
267
257
- The object ID of your application's service principal, found in the Overview blade of your application's entry in Enterprise Applications in the Azure portal.
268
258
- An app registration to sign in a user and get an access token to call Microsoft Graph. Get the application (client) ID of this app in the Overview blade of the application's entry in App registrations in the Azure portal. The app registration should have the following configuration:
For single tenant apps, you can set the `acceptMappedClaims` property to `true` in the [application manifest](reference-app-manifest.md). As documented on the [apiApplication resource type](/graph/api/resources/apiapplication?view=graph-rest-1.0&preserve-view=true#properties), this allows an application to use claims mapping without specifying a custom signing key.
461
+
For single tenant apps, you can set the `acceptMappedClaims` property to `true` in the [application manifest](reference-app-manifest.md). As documented on the [apiApplication resource type](/graph/api/resources/apiapplication?view=graph-rest-1.0&preserve-view=true#properties). Setting the property allows an application to use claims mapping without specifying a custom signing key.
472
462
473
463
>[!WARNING]
474
464
>Do not set the acceptMappedClaims property to true for multi-tenant apps, which can allow malicious actors to create claims-mapping policies for your app.
Copy file name to clipboardExpand all lines: articles/active-directory/develop/optional-claims.md
+10-25Lines changed: 10 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,9 +17,8 @@ ms.reviewer: ludwignick
17
17
18
18
You can configure optional claims for your application through the Azure portal or application manifest.
19
19
20
-
1. Sign in to the [Azure portal](https://portal.azure.com).
21
-
1. Search for and select **Azure Active Directory**.
22
-
1. Under **Manage**, select **App registrations**.
20
+
1. Sign in to the [Microsoft Entra admin center](https://entra.microsoft.com) as at least a [Cloud Application Administrator](../roles/permissions-reference.md#cloud-application-administrator).
21
+
1. Browse to **Identity** > **Applications** > **App registrations**.
23
22
1. Choose the application for which you want to configure optional claims based on your scenario and desired outcome.
24
23
1. Under **Manage**, select **Token configuration**.
25
24
- The UI option **Token configuration** blade isn't available for apps registered in an Azure AD B2C tenant, which can be configured by modifying the application manifest. For more information, see [Add claims and customize user input using custom policies in Azure Active Directory B2C](../../active-directory-b2c/configure-user-input.md)
@@ -107,11 +106,7 @@ This section covers the configuration options under optional claims for changing
107
106
108
107
Complete the following steps to configure groups optional claims using the Azure portal:
109
108
110
-
1. Sign in to the [Azure portal](https://portal.azure.com).
111
-
1. After you've authenticated, choose your tenant by selecting it from the top-right corner of the page.
112
-
1. Search for and select **Azure Active Directory**.
113
-
1. Under **Manage**, select **App registrations**.
114
-
1. Select the application you want to configure optional claims for in the list.
109
+
1. Select the application for which you want to configure optional claims.
115
110
1. Under **Manage**, select **Token configuration**.
116
111
1. Select **Add groups claim**.
117
112
1. Select the group types to return (**Security groups**, or **Directory roles**, **All groups**, and/or **Groups assigned to the application**):
@@ -122,10 +117,7 @@ Complete the following steps to configure groups optional claims using the Azure
122
117
123
118
Complete the following steps to configure groups optional claims through the application manifest:
124
119
125
-
1. Sign in to the [Azure portal](https://portal.azure.com).
126
-
1. After you've authenticated, choose your Azure AD tenant by selecting it from the top-right corner of the page.
127
-
1. Search for and select **Azure Active Directory**.
128
-
1. Select the application you want to configure optional claims for in the list.
120
+
1. Select the application for which you want to configure optional claims.
129
121
1. Under **Manage**, select **Manifest**.
130
122
1. Add the following entry using the manifest editor:
131
123
@@ -150,11 +142,11 @@ Complete the following steps to configure groups optional claims through the app
150
142
151
143
Multiple token types can be listed:
152
144
153
-
- idToken for the OIDC ID token
154
-
- accessToken for the OAuth access token
155
-
- Saml2Token for SAML tokens.
145
+
- `idToken` for the OIDC ID token
146
+
- `accessToken` for the OAuth access token
147
+
- `Saml2Token` for SAML tokens.
156
148
157
-
The Saml2Token type applies to both SAML1.1 and SAML2.0 format tokens.
149
+
The `Saml2Token` type applies to both SAML1.1 and SAML2.0 format tokens.
158
150
159
151
For each relevant token type, modify the groups claim to use the `optionalClaims` section in the manifest. The `optionalClaims` schema is as follows:
160
152
@@ -264,11 +256,7 @@ In the following example, the Azure portal and manifest are used to add optional
264
256
265
257
Configure claims in the Azure portal:
266
258
267
-
1. Sign in to the [Azure portal](https://portal.azure.com).
268
-
1. After you've authenticated, choose your tenant by selecting it from the top-right corner of the page.
269
-
1. Search for and select **Azure Active Directory**.
270
-
1. Under **Manage**, select **App registrations**.
271
-
1. Find the application you want to configure optional claims for in the list and select it.
259
+
1. Select the application for which you want to configure optional claims.
272
260
1. Under **Manage**, select **Token configuration**.
273
261
1. Select **Add optional claim**, select the **ID** token type, select **upn** from the list of claims, and then select **Add**.
274
262
1. Select **Add optional claim**, select the **Access** token type, select **auth_time** from the list of claims, then select **Add**.
@@ -277,10 +265,7 @@ Configure claims in the Azure portal:
277
265
278
266
Configure claims in the manifest:
279
267
280
-
1. Sign in to the [Azure portal](https://portal.azure.com).
281
-
1. After you've authenticated, choose your tenant by selecting it from the top-right corner of the page.
282
-
1. Search for and select **Azure Active Directory**.
283
-
1. Find the application you want to configure optional claims for in the list and select it.
268
+
1. Select the application for which you want to configure optional claims.
284
269
1. Under **Manage**, select **Manifest** to open the inline manifest editor.
285
270
1. You can directly edit the manifest using this editor. The manifest follows the schema for the [Application entity](./reference-app-manifest.md), and automatically formats the manifest once saved. New elements are added to the `optionalClaims` property.
0 commit comments