Skip to content

Commit 88340a1

Browse files
authored
Merge pull request #229157 from yoelhor/patch-331
[Azure AD] Custom extension feature
2 parents b519422 + b560467 commit 88340a1

18 files changed

+1187
-1
lines changed

articles/active-directory/develop/TOC.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@
6969
href: active-directory-how-applications-are-added.md
7070
- name: Single-tenant and multi-tenant apps
7171
href: single-and-multi-tenant-apps.md
72+
- name: Custom Authentication Extensions
73+
displayName: Custom Authentication Extensions
74+
items:
75+
- name: Overview
76+
href: custom-extension-overview.md
77+
- name: Custom claims provider
78+
href: custom-claims-provider-overview.md
7279
- name: Security best practices
7380
displayName: least privilege, secure app configuration, conditional access
7481
items:
@@ -135,6 +142,16 @@
135142
- name: SAML app multi-instancing
136143
displayName: Configure SAML app multi-instancing for an application
137144
href: reference-app-multi-instancing.md
145+
- name: Custom claims provider
146+
items:
147+
- name: Token issuance start event
148+
items:
149+
- name: Create and register a custom claims provider API
150+
href: custom-extension-get-started.md
151+
- name: Configure a SAML app to call a custom claims provider
152+
href: custom-extension-configure-saml-app.md
153+
- name: Troubleshoot your custom claims provider API
154+
href: custom-extension-troubleshoot.md
138155
- name: Handle browser cookie restrictions
139156
items:
140157
- name: Handle ITP in Safari
@@ -826,6 +843,8 @@
826843
href: authentication-national-cloud.md
827844
- name: Microsoft Graph API reference (identity operations)
828845
href: /graph/api/resources/azure-ad-overview
846+
- name: Custom claims provider reference
847+
href: custom-claims-provider-reference.md
829848
- name: Resources
830849
items:
831850
- name: Help and support options
@@ -835,7 +854,7 @@
835854
href: reference-breaking-changes.md
836855
- name: Video learning
837856
href: identity-videos.md
838-
- name: "Blog: M365 Developer - Microsoft identity platform"
857+
- name: "Blog: Microsoft 365 Developer - Microsoft identity platform"
839858
href: https://devblogs.microsoft.com/microsoft365dev/category/microsoft-identity-platform/
840859
- name: "Blog: Azure AD - Identity"
841860
href: https://techcommunity.microsoft.com/t5/azure-active-directory-identity/bg-p/Identity
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Custom claims provider overview
3+
titleSuffix: Microsoft identity platform
4+
description: Conceptual article describing the custom claims provider as part of the custom authentication extension framework.
5+
services: active-directory
6+
author: yoelhor
7+
manager: CelesteDG
8+
9+
ms.service: active-directory
10+
ms.subservice: develop
11+
ms.workload: identity
12+
ms.topic: conceptual
13+
ms.date: 03/06/2023
14+
ms.author: davidmu
15+
ms.reviewer: JasSuri
16+
ms.custom: aaddev
17+
#Customer intent: As a developer, I want to learn about custom claims provider so that I can augment tokens with claims from an external identity system or role management system.
18+
---
19+
20+
# Custom claims provider (preview)
21+
22+
This article provides an overview to the Azure Active Directory (Azure AD) custom claims provider.
23+
When a user authenticates to an application, a custom claims provider can be used to add claims into the token. A custom claims provider is made up of a custom extension that calls an external REST API, to fetch claims from external systems. A custom claims provider can be assigned to one or many applications in your directory.
24+
25+
Key data about a user is often stored in systems external to Azure AD. For example, secondary email, billing tier, or sensitive information. Some applications may rely on these attributes for the application to function as designed. For example, the application may block access to certain features based on a claim in the token.
26+
27+
Use a custom claims provider for the following scenarios:
28+
29+
- **Migration of legacy systems** - You may have legacy identity systems such as Active Directory Federation Services (AD FS) or data stores (such as LDAP directory) that hold information about users. You'd like to migrate these applications, but can't fully migrate the identity data into Azure AD. Your apps may depend on certain information on the token, and can't be rearchitected.
30+
- **Integration with other data stores that can't be synced to the directory** - You may have third-party systems, or your own systems that store user data. Ideally this information could be consolidated, either through [synchronization](../cloud-sync/what-is-cloud-sync.md) or direct migration, in the Azure AD directory. However, that isn't always feasible. The restriction may be because of data residency, regulations, or other requirements.
31+
32+
## Token issuance start event listener
33+
34+
An event listener is a procedure that waits for an event to occur. The custom extension uses the **token issuance start** event listener. The event is triggered when a token is about to be issued to your application. When the event is triggered the custom extension REST API is called to fetch attributes from external systems.
35+
36+
For an example using a custom claims provider with the **token issuance start** event listener, check out the [get started with custom claims providers](custom-extension-get-started.md) article.
37+
38+
## Next steps
39+
40+
- Learn how to [create and register a custom claims provider](custom-extension-get-started.md) with a sample Open ID Connect application.
41+
- If you already have a custom claims provider registered, you can configure a [SAML application](custom-extension-configure-saml-app.md) to receive tokens with claims sourced from an external store.
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
---
2+
title: Custom claims provider reference
3+
titleSuffix: Microsoft identity platform
4+
description: Reference documentation for custom claims providers
5+
services: active-directory
6+
author: jassuri
7+
manager: CelesteDG
8+
9+
ms.service: active-directory
10+
ms.subservice: develop
11+
ms.workload: identity
12+
ms.topic: conceptual
13+
ms.date: 03/06/2023
14+
ms.author: davidmu
15+
ms.reviewer: jassuri
16+
ms.custom: aaddev
17+
#Customer intent: As a developer, I want to learn about custom authentication extensions so that I can augment tokens with claims from an external identity system or role management system.
18+
---
19+
20+
# Custom claims providers
21+
22+
In this reference article, you can learn about the REST API schema and claims mapping policy structure for custom claim provider events.
23+
24+
## Token issuance start event
25+
26+
The custom claims provider token issuance event allows you to enrich or customize application tokens with information from external systems. This information that can't be stored as part of the user profile in Azure AD directory.
27+
28+
### Component overview
29+
30+
To set up and, integrate a custom extension with your application requires multiple components to be connected. The following diagram shows a high level view of the configuration points, and relationships that are created to implement a custom extension.
31+
32+
:::image type="content" border="false" source="media/custom-extension-get-started/token-issuance-start-config.png" alt-text="Screenshot that shows the components to configure in Azure AD to set up and integrate a custom claims provider." lightbox="media/custom-extension-get-started/token-issuance-start-config.png":::
33+
34+
- You should have a **REST API endpoint** publicly available. In this diagram, it represented by Azure Function. The REST API generates and returns custom claims to the custom extension. It's associated with an Azure AD application registration.
35+
- You require to configure a **custom extension** in Azure AD, which is configured to connect to your API.
36+
- You require an **application** that receives the customized tokens. For example <https://jwt.ms> a Microsoft-owned web application that displays the decoded contents of a token.
37+
- The application, such as the <https://jwt.ms> must be registered into Azure AD using **app registration**.
38+
- You must create an association between your application and your custom extension.
39+
- You can optionally secure the Azure Function with an authentication provider, in this article we use your Azure AD.
40+
41+
### REST API
42+
43+
Your REST API endpoint is responsible for interfacing with downstream services. For example, databases, other REST APIs, LDAP directories, or any other stores that contain the attributes you'd like to add to the token configuration.
44+
45+
The REST API returns an HTTP response to Azure AD containing the attributes. Attributes that return by your REST API aren't automatically added into a token. Instead, an application's claims mapping policy must be configured for any attribute to be included in the token. In Azure AD, a claims mapping policy modifies the claims emitted in tokens issued for specific applications.
46+
47+
### REST API schema
48+
49+
To develop your own REST API for the token issuance start event, use the following REST API data contract. The schema describes the contract to design the request and response handler.
50+
51+
Your custom extension in Azure AD makes an HTTP call to your REST API with a JSON payload. The JSON payload contains user profile data, authentication context attributes, and information about the application the user wants to sign-in. The JSON attributes can be used to perform extra logic by your API. The request to your API is in the following format:
52+
53+
```json
54+
{
55+
"type": "microsoft.graph.authenticationEvent.tokenIssuanceStart",
56+
"source": "/tenants/<Your tenant GUID>/applications/<Your Test Application App Id>",
57+
"data": {
58+
"@odata.type": "microsoft.graph.onTokenIssuanceStartCalloutData",
59+
"tenantId": "<Your tenant GUID>",
60+
"authenticationEventListenerId": "<GUID>",
61+
"customAuthenticationExtensionId": "<Your custom extension ID>",
62+
"authenticationContext": {
63+
"correlationId": "<GUID>",
64+
"client": {
65+
"ip": "30.51.176.110",
66+
"locale": "en-us",
67+
"market": "en-us"
68+
},
69+
"protocol": "OAUTH2.0",
70+
"clientServicePrincipal": {
71+
"id": "<Your Test Applications servicePrincipal objectId>",
72+
"appId": "<Your Test Application App Id>",
73+
"appDisplayName": "My Test application",
74+
"displayName": "My Test application"
75+
},
76+
"resourceServicePrincipal": {
77+
"id": "<Your Test Applications servicePrincipal objectId>",
78+
"appId": "<Your Test Application App Id>",
79+
"appDisplayName": "My Test application",
80+
"displayName": "My Test application"
81+
},
82+
"user": {
83+
"createdDateTime": "2016-03-01T15:23:40Z",
84+
"displayName": "Bob",
85+
"givenName": "Bob Smith",
86+
"id": "90847c2a-e29d-4d2f-9f54-c5b4d3f26471",
87+
"mail": "[email protected]",
88+
"preferredLanguage": "en-us",
89+
"surname": "Smith",
90+
"userPrincipalName": "[email protected]",
91+
"userType": "Member"
92+
}
93+
}
94+
}
95+
}
96+
```
97+
98+
The REST API response format which Azure expects is in the following format, where the claims `DateOfBirth` and `CustomRoles` are returned to Azure:
99+
100+
```json
101+
{
102+
"data": {
103+
"@odata.type": "microsoft.graph.onTokenIssuanceStartResponseData",
104+
"actions": [
105+
{
106+
"@odata.type": "microsoft.graph.tokenIssuanceStart.provideClaimsForToken",
107+
"claims": {
108+
"DateOfBirth": "01/01/2000",
109+
"CustomRoles": [
110+
"Writer",
111+
"Editor"
112+
]
113+
}
114+
}
115+
]
116+
}
117+
}
118+
```
119+
120+
When a B2B user from Fabrikam organization authenticates to Contoso's organization, the request payload sent to the REST API has the `user` element in the following format:
121+
122+
```json
123+
"user": {
124+
"companyName": "Fabrikam",
125+
"createdDateTime": "2022-07-15T00:00:00Z",
126+
"displayName": "John Wright",
127+
"id": "12345678-0000-0000-0000-000000000000",
128+
"mail": "[email protected]",
129+
"preferredDataLocation": "EUR",
130+
"userPrincipalName": "johnwright_fabrikam.com#EXT#@contoso.onmicrosoft.com",
131+
"userType": "Guest"
132+
}
133+
```
134+
135+
### Supported data types
136+
137+
The following table shows the data types supported by Custom claims providers for the token issuance start event:
138+
139+
| Data type | Supported |
140+
|--------------|-----------|
141+
| String | True |
142+
| String array | True |
143+
| Boolean | False |
144+
| JSON | False |
145+
146+
### Claims mapping policy
147+
148+
In Azure AD, a claims mapping policy modifies the claims emitted in tokens issued for specific applications. It includes claims from your custom claims provider, and issuing them into the token.
149+
150+
```json
151+
{
152+
"ClaimsMappingPolicy": {
153+
"Version": 1,
154+
"IncludeBasicClaimSet": "true",
155+
"ClaimsSchema": [{
156+
"Source": "CustomClaimsProvider",
157+
"ID": "dateOfBirth",
158+
"JwtClaimType": "birthdate"
159+
},
160+
{
161+
"Source": "CustomClaimsProvider",
162+
"ID": "customRoles",
163+
"JwtClaimType": "my_roles"
164+
},
165+
{
166+
"Source": "CustomClaimsProvider",
167+
"ID": "correlationId",
168+
"JwtClaimType": "correlation_Id"
169+
},
170+
{
171+
"Source": "CustomClaimsProvider",
172+
"ID": "apiVersion",
173+
"JwtClaimType": "apiVersion"
174+
},
175+
{
176+
"Value": "tokenaug_V2",
177+
"JwtClaimType": "policy_version"
178+
}]
179+
}
180+
}
181+
```
182+
183+
The `ClaimsSchema` element contains the list of claims to be mapped with the following attributes:
184+
185+
- **Source** describes the source of the attribute, the `CustomClaimsProvider`. Note, the last element contains a fixed value with the policy version, for testing purposes. Thus, the `source` attribute is omitted.
186+
187+
- **ID** is the name of the claims at it returns from the Azure Function you created.
188+
189+
> [!IMPORTANT]
190+
> The ID attribute's value is case sensitive. Make sure you type the claim name exactly as it returned by the Azure Function.
191+
- **JwtClaimType** is an optional name of claim in the emitted token for OpenID Connect app. It allows you to provide a different name that returns in the JWT token. For example, if the API response has an `ID` value of `dateOfBirth`, it can be emitted as `birthdate` in the token.
192+
193+
Once you create your claims mapping policy, the next step is to upload it to your Azure AD tenant. Use the following [claimsMappingPolicy](/graph/api/claimsmappingpolicy-post-claimsmappingpolicies) Graph API in your tenant.
194+
195+
> [!IMPORTANT]
196+
> The **definition** element should be an array with a single string value. The string should be the stringified and escaped version of your claims mapping policy. You can use tools like [https://jsontostring.com/](https://jsontostring.com/) to stringify your claims mapping policy.
197+
198+
## Next steps
199+
200+
- To learn how to [create and register a custom extension and API endpoint](custom-extension-get-started.md).
201+
- To learn how to customize the claims emitted in tokens for a specific application in their tenant using PowerShell, see [How to: Customize claims emitted in tokens for a specific app in a tenant](active-directory-claims-mapping.md)
202+
- To learn how to customize claims issued in the SAML token through the Azure portal, see [How to: Customize claims issued in the SAML token for enterprise applications](active-directory-saml-claims-customization.md)
203+
- To learn more about extension attributes, see [Using directory extension attributes in claims](active-directory-schema-extensions.md).

0 commit comments

Comments
 (0)