Basic understanding on Microsoft Entra custom claims provider (2024)

TOC

  1. What is it
  2. Architecture
  3. How to use it
  4. References

What is it

When a user authenticates to an app (e.g., MS Entra ID application), a custom claims provider can be used to add claims into the token. A custom claims provider is made up of a custom authentication extension that calls an external REST API (e.g., a Function App), to fetch claims from external systems (e.g., a Database). A custom claims provider can be assigned to one or many applications.

Claim: Please imagine it as features (or attributes) that belong to the end user. As it may involve sensitive information within the enterprise, the enterprise owner wishes to store this user information in the on-premises environment, while also hoping to retrieve and utilize it through the authentication process.

This service is suitable for the following scenarios:

1) It can be used as a transition for gradually migrating on-premises Active Directory to Microsoft Azure AD.

2) When user-sensitive information needs to be stored in an on-premises environment for various reasons.

Architecture

Basic understanding on Microsoft Entra custom claims provider (1)

Procedure:

  1. User login to the Application
  2. If this AAD includes a custom claims provider, then the relevant features need to be obtained from the custom claims provider before generating the token.
  3. The Custom claims provider asking our own system (e.g., a Function App) for the claims (e.g., criminal record) related to that user.
  4. Our system get the related claims (e.g., by querying DB) and return it to the Custom claims provider.
  5. The custom claims provider packages the default user information along with the additionally obtained claims, encodes them into a token, and returns it to the user.

How to use it

A-1: Create a Function App from Azure portal

Choose ".NET 6 (LTS), in-process model" as the runtime and "Windows" as the OS.

Basic understanding on Microsoft Entra custom claims provider (2)

A-2: Setup a local project via VSCode

  1. Open VSCode.
  2. Create a new folder for your project (e.g., ccp-func)
  3. Under the Workspace bar, select the Azure Functions icon > Create New Project.
  4. Select C# as the language, and .NET 6.0 LTS as the .NET runtime.
  5. Select HTTP trigger as the template.
  6. Provide a name for the trigger (e.g., AuthEventsTrigger)
  7. Accept Company.Function as the namespace, with AccessRights set to Function.
  8. Open the terminal, navigate to the project folder and enter the following:

dotnet add package Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents --prerelease

A-3: Add/Modify the sample code

  1. Open the *.csproj file, change the AuthenticationEvents version to "1.0.0-beta.6"

Basic understanding on Microsoft Entra custom claims provider (3)

  1. Open the AuthEventsTrigger.cs file, copy and paste the following code to replace
using System;using System.Threading.Tasks;using Microsoft.AspNetCore.Mvc;using Microsoft.Azure.WebJobs;using Microsoft.Extensions.Logging;using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart.Actions;using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.TokenIssuanceStart;using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents.Framework;using Microsoft.Azure.WebJobs.Extensions.AuthenticationEvents; namespace AuthEventTrigger{ public static class Function1 { [FunctionName("onTokenIssuanceStart")] public static AuthenticationEventResponse Run( [AuthenticationEventsTrigger(AudienceAppId = "TBA", AuthorityUrl = "https://login.microsoftonline.com/TBA", AuthorizedPartyAppId = "99045fe1-7639-4a75-9d4a-577b6ca3810f")]TokenIssuanceStartRequest request, ILogger log) { try { if (request.RequestStatus == RequestStatusType.Successful) { request.Response.Actions.Add(new ProvideClaimsForToken( new TokenClaim("dateOfBirth", "01/01/2000"), new TokenClaim("customRoles", "Writer", "Editor"), new TokenClaim("apiVersion", "1.0.0"), new TokenClaim("correlationId", request.Data.AuthenticationContext.CorrelationId.ToString()) )); } else { log.LogInformation(request.StatusMessage); } return request.Completed(); } catch (Exception ex) { return request.Failed(ex); } } }}
  1. As you can see that there are two instances of "TBA" in the code, indicating that some of the configuration content needs to be acquired in subsequent operations. Therefore, we will maintain this status for now.
  2. Publish the project to the Function App
  3. On Azure Portal, go to that Function App and onTokenIssuanceStart trigger, copy the Function URL for further use.

Format: https://xxx.azurewebsites.net/runtime/webhooks/customauthenticationextension?functionName=onTokenIss...

Basic understanding on Microsoft Entra custom claims provider (4)

B-1: Register a custom authentication extension

  1. In Azure Portal, go to Microsoft Entra ID and select Enterprise applications.
  2. Select Custom authentication extensions, and then select Create a custom extension.
  3. In Basics, select the TokenIssuanceStart event type and select Next.
  4. In Endpoint Configuration, fill in the following properties:

Name: (e.g., CCP Token issuance event)

Target Url: The URL you've get from A-3 step 5.

Select Next.

  1. In API Authentication, select the Create new app registration option to create an app registration that represents your function app.

Give the app a name (e.g., CCP Azure Functions authentication events API)

Select Next.

  1. In Claims, enter the attributes (Claims) that you expect your custom authentication extension to parse from your REST API and will be merged into the token. Add the following claims:

dateOfBirth

customRoles

apiVersion

correlationId

  1. Select Next, then Create.
  2. Note the App ID under API Authentication, which is needed for setting environment variables in your Azure Function app.

Basic understanding on Microsoft Entra custom claims provider (5)

Basic understanding on Microsoft Entra custom claims provider (6)

  1. Under API Authentication, select Grant permission.
  2. A new window opens, and once signed in, it requests permissions to receive custom authentication extension HTTP requests. This allows the custom authentication extension to authenticate to your API. Select Accept.

Basic understanding on Microsoft Entra custom claims provider (7)

C-1: Configure an App to receive enriched tokens

  1. In Azure Portal, go to Microsoft Entra ID and select App registrations.
  2. Select New registration.
  3. Enter a Name for the application (e.g., CCP test application)

Under Supported account types, select Accounts in this organizational directory only.

In the Select a platform dropdown in Redirect URI, select Web and then enter https://jwt.ms in the URL text box.

Select Register to complete the app registration.

  1. Copy Application ID and Tenant ID for further use.

Basic understanding on Microsoft Entra custom claims provider (8)

Basic understanding on Microsoft Entra custom claims provider (9)

  1. Back to the app in Azure portal, go to Manage, select Authentication.

Under Implicit grant and hybrid flows, select the ID tokens (used for implicit and hybrid flows) checkbox.

Select Save.

  1. Back to the app in Azure portal, go to Manage, select Manifest.

Set the acceptMappedClaims to true.

Set the accessTokenAcceptedVersion to 2.

Select Save to save the changes.

Basic understanding on Microsoft Entra custom claims provider (10)

B-2: Assign a custom claims provider to your app

  1. In Azure Portal, go to Microsoft Entra ID and select Enterprise applications.
  2. Under Manage, select All applications. Find and select (e.g., CCP test application) from the list.

From the Overview page, navigate to Manage, and select Single sign-on.

Under Attributes & Claims, select Edit.

Expand the Advanced settings menu.

Next to Custom claims provider, select Configure.

Expand the Custom claims provider drop-down box, and select the (e.g., CCP Token issuance event) you created earlier.

Select Save.

  1. Next, assign the attributes from the custom claims provider, which should be issued into the token as claims:

Select Add new claim to add a new claim. Provide a name to the claim you want to be issued, for example dateOfBirth.

Under Source, select Attribute, and choose customClaimsProvider.dateOfBirth from the Source attribute drop-down box.

Basic understanding on Microsoft Entra custom claims provider (11)

  1. Repeat this process to add the customClaimsProvider.customRoles, customClaimsProvider.apiVersion and customClaimsProvider.correlationId attributes, and the corresponding name.

A-4: Protect your Azure Function

  1. In Azure Portal, go to the Function App
  2. Under Settings, select Authentication.
  3. Select Add Identity provider.
  4. Select Microsoft as the identity provider.

Select Workforce configuration (current tenant).

Under App registration select Pick an existing app registration in this directory for the App registration type, and pick the (e.g., CCP Azure Functions authentication events API).

Enter the following issuer URL, https://login.microsoftonline.com/{tenantId}/v2.0, where {tenantId} is the tenant ID you've get from C-1 step 4.

Under Client application requirement, select Allow requests from specific client applications, in Allowed client applications click edit button and add 2 app ids (The id you've get from B-1 step 8 and a fixed one 99045fe1-7639-4a75-9d4a-577b6ca3810f).

Basic understanding on Microsoft Entra custom claims provider (12)

Under Identity requirement, select Allow requests from any identity.

Under Tenant requirement, select Use default restrictions based on issuer.

Under Unauthenticated requests, select HTTP 401 Unauthorized as the identity provider.

Unselect the Token store option.

Select Add to add authentication to your Azure Function.

A-5: Modify the sample code

  1. We have noticed that there are 2 TBA in the code and already know what is the related value. So we could deploy it again to the Function App.

Basic understanding on Microsoft Entra custom claims provider (13)

B-3: Test

  1. We could have a test on the whole process, open a browser and visit the following URL

https://login.microsoftonline.com/{tenantId}/oauth2/v2.0/authorize?client_id={App_to_enrich_ID}&resp...

{tenantId} stands for the Tenant ID you've get from C-1 step 4

{App_to_enrich_ID} stands for the Application ID you've get from C-1 step 4

  1. After the login we could see the result, which the returned token containing the related claims

Basic understanding on Microsoft Entra custom claims provider (14)

References

Custom claims provider overview - Microsoft identity platform | Microsoft Learn

Create a REST API with a token issuance start event for Azure Functions (preview) - Microsoft identi...

Custom claims provider: Configure a token issuance event - Microsoft identity platform | Microsoft L...

Authentication events trigger for Azure Functions client library for .NET - Azure for .NET Developer...

Basic understanding on Microsoft Entra custom claims provider (2024)

FAQs

What is a custom claims provider? ›

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 Microsoft Entra directory.

What is Microsoft Entra used for? ›

Azure Active Directory (Azure AD), now known as Microsoft Entra ID, is an identity and access management solution from Microsoft that helps organizations secure and manage identities for hybrid and multicloud environments.

How to test Microsoft Entra ID? ›

To test your user flow
  1. Sign in to the Microsoft Entra admin center.
  2. Browse to Identity > External Identities > User flows.
  3. Select your user flow from the list. ...
  4. Select the Run user flow button.
  5. Select the Run user flow button, or copy the Run user flow endpoint URL into a new browser window.
Apr 11, 2024

What is Microsoft Entra ID in the authenticator app? ›

Microsoft Entra multifactor authentication adds additional security over only using a password when a user signs in. The user can be prompted for additional forms of authentication, such as to respond to a push notification, enter a code from a software or hardware token, or respond to a text message or phone call.

What are custom claims? ›

A custom claims provider is made up of a custom authentication 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. Key data about a user is often stored in systems external to Microsoft Entra ID.

What processes claims for providers? ›

A medical claims clearinghouse is an electronic intermediary between healthcare providers and payors. Healthcare providers transmit their medical claims to a clearinghouse. Clearinghouses then scrub, standardize and screen medical claims before sending them to the payor.

What is part of Microsoft Entra? ›

Microsoft Entra ID is Microsoft's cloud-based identity and access management solution, which helps your employees and guest users sign in securely and access resources such as Microsoft apps (for example, Microsoft 365 and Azure), thousands of pre-integrated popular SaaS apps (for example, ServiceNow, Google apps), and ...

What is Microsoft Entra replacing? ›

Microsoft Entra ID is the new name for Azure AD. The names Azure Active Directory, Azure AD, and AAD are replaced with Microsoft Entra ID. Microsoft Entra is the name for the product family of identity and network access solutions.

Which two services are provided by Microsoft Entra? ›

Microsoft Entra is a suite of identity and access capabilities. Out of the options provided, the two services that are associated with Microsoft Entra include authentication and single sign-on (SSO). Authentication is a process that verifies the identity of a user or device.

How does Microsoft Entra ID work? ›

App developers can use Microsoft Entra ID as a standards-based authentication provider that helps them add single sign-on (SSO) to apps that works with a user's existing credentials. Developers can also use Microsoft Entra APIs to build personalized experiences using organizational data.

How to setup MS Entra? ›

Sign in to the Microsoft Entra admin center as at least a Global Administrator. Select Verifiable credentials. From the left menu, select Setup. From the middle menu, select Register decentralized ID to register your DID document, as per instructions in article How to register your decentralized ID for did:web.

How to implement Microsoft Entra ID? ›

Set up Verified ID
  1. Sign in to the Microsoft Entra admin center as at least a Global Administrator.
  2. Select Verified ID.
  3. From the left menu, select Setup.
  4. Click the Get started button.
  5. If you have multiple domains registered for your Microsoft Entra tenant, select the one you would like to use for Verified ID.
Feb 20, 2024

What is the difference between Microsoft Authenticator and Microsoft Entra? ›

Microsoft Entra ID lets you choose which authentication methods can be used during the sign-in process. Users then register for the methods they'd like to use. The Microsoft Authenticator authentication method policy manages both the traditional push MFA method and the passwordless authentication method.

What are the three types of authentication? ›

There are three authentication factors that can be used: something you know, something you have, and something you are. Something you know would be a password, a PIN, or some other personal information.

Which three tasks can be performed by using Microsoft Entra ID protection? ›

Microsoft Entra ID Protection helps organizations detect, investigate, and remediate identity-based risks.

What are custom claims in Firebase? ›

Custom claims apply to users already signed in with supported providers (Email/Password, Google, Facebook, phone, etc). For example, a user signed in with Firebase Auth's Email/Password provider can have access control defined using custom claims.

What is an insurance claims agent? ›

Insurance claims representatives work for insurance companies to initiate, investigate and process claims that customers report. This role helps ensure the insurance company and the policyholder come to an agreement regarding a claim.

Can a provider submit paper claims to Medicare? ›

Methods of Submission

Claims may be filed to Noridian electronically (this applies to most Medicare providers) or on paper (if certain conditions or exceptions exist).

What is a CID claim? ›

The Claim Identifier (CID) Status Lookup allows access to inquire on the outcomes of CERT Claims. A CID may be used to find a specific claim, or a listing of all CERT claims can be found by the provider/supplier details.

Top Articles
Latest Posts
Article information

Author: Barbera Armstrong

Last Updated:

Views: 6202

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Barbera Armstrong

Birthday: 1992-09-12

Address: Suite 993 99852 Daugherty Causeway, Ritchiehaven, VT 49630

Phone: +5026838435397

Job: National Engineer

Hobby: Listening to music, Board games, Photography, Ice skating, LARPing, Kite flying, Rugby

Introduction: My name is Barbera Armstrong, I am a lovely, delightful, cooperative, funny, enchanting, vivacious, tender person who loves writing and wants to share my knowledge and understanding with you.