TL;DR
- An authentication context is a label such as c1 that a Conditional Access policy can target, so one action inside an app can ask for more than the rest.
- The app does the asking: it checks the token for the label and, if it is missing, answers with a claims challenge.
- A label without a policy may still be issued, so check that the policy exists and is switched on.
- You need Microsoft Entra identifier (ID) P1 and an app that signs in a person. Apps that sign in as themselves are not supported.
The problem it solves#
A rule that asks for multi-factor authentication (MFA) on a whole app is blunt. Reading a list of orders gets the same treatment as sending money. Make it strict and people get prompted all day; make it loose and the payment is barely protected.
See it run: the lab with the real Authenticator prompt.
What it is#
An authentication context is a named label in your tenant. Its ID is one of c1 to c99, and you give it a name such as “payment approval”. A Conditional Access policy can target the label instead of a whole app, and say what it takes to get it: for example MFA, a compliant device or a trusted location.
When a person meets the policy, Entra can put the label in their token, in a claim called acrs. Your app reads that claim.
Think of an office building. The badge at the front door gets you in. One room has a second reader, and the room decides when to ask for it.
How the step-up runs#
- The app calls the API with the token it already has.
- For a sensitive action, the API looks for the right label in
acrs. If it is missing, it answers401with aWWW-Authenticateheader. - That header carries
error="insufficient_claims"and aclaimsvalue: a small piece of JSON, base64 encoded. - The app decodes it and sends the person back to Entra with it in the sign-in request.
- Entra applies the policy for that label. The person completes what it demands.
- The app receives a new token carrying the label and repeats the request.
For the label c1, the decoded request looks like this:
{"access_token":{"acrs":{"essential":true,"value":"c1"}}}An app should also tell Entra that it can handle such challenges. It declares the client capability cp1; an API that asks for the xms_cc optional claim can then see it in the token and answer older clients differently.
Who does what#
The tenant administrator creates the label, publishes it to apps and writes the policy. The developer decides which actions check for a label, and should let an administrator choose which one, because label IDs differ between tenants. Microsoft advises against writing c1 into the code; the app can list the available labels through Microsoft Graph.
Where it surprises people#
A label with no policy. Microsoft’s guidance says that when no policy is assigned to a label, the claim might still be issued, because there is nothing left to satisfy. If your API trusts the label and the policy is missing or off, the extra check may not happen. Treat the policy as part of the feature.
No prompt at all. A token can receive the label without a new challenge when the sign-in already satisfies the policy and the app has opted in to the optional acrs claim. A person who did MFA a moment ago may see nothing new.
Deleting a label. Check first that no app still uses it. Entra only lets you delete one that has no policy and is not published to apps.
Whole-app policies. Microsoft advises against using authentication context where the app itself is already the target of Conditional Access policies. The feature fits best when only parts of an app need the higher bar.
What you need#
- Microsoft Entra ID P1 or higher, because this is part of Conditional Access.
- An app that signs people in with OpenID Connect or OAuth 2.0. Applications that authenticate as themselves are not supported for this app scenario.
- Code that returns the challenge in the API, and code in the client that catches it.
Microsoft also documents the same labels for SharePoint sites, Privileged Identity Management role activation and Defender for Cloud Apps, where you configure them instead of writing code.
Sources#
This post as Markdown · RSS · JSON feed
New posts by email
One email a week with new posts and labs. Unsubscribe anytime.
Your address is stored with Kit, which sends the emails. Details