Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Conditional access policies

A conditional access policy attaches a condition to one action, such as a stronger sign-in before Omar downloads an unpublished original. The API names what is missing, the authorization server collects it, and only that action asks for more.

Conditions on one action

All names, domains, and identifiers in these examples are fictional. At the end of Context, devices, and risk, the photo service gave Nia, one of its picture editors, a second way to download an unpublished photo from a café by the river: on a personal laptop, she could still have the full-resolution file if she had signed in with a passkey in the last 15 minutes. The Gazette has adopted the same rule for its own picture editors, such as Omar, who work away from the newsroom, and calls it the café rule. That lesson decided what evidence was enough. This one follows how the request actually gets it: how the policy is written, how the photo API tells the application what is missing, and how the application comes back with it.

A conditional access policy attaches conditions to access that a permission alone would allow. Omar is a picture editor in the Sports library, so his permissions let him download photo 9001. The policy adds that, for this action and this kind of resource, a particular combination of circumstances needs more evidence before the download goes ahead.

Most products that offer conditional access describe a policy in the same four parts: who it applies to, what it protects, the conditions under which it applies, and what it requires when they hold. Written that way, the Gazette's café rule looks like this:

policy:      Unpublished originals on unmanaged devices
applies to:  members of Picture editors
protects:    photo API, action photo.download,
             photos with status draft or approved
when:        device is not managed
             and sign-in risk is low
requires:    a passkey sign-in within the last 15 minutes
when risk is not low: deny

Each part narrows the policy. Viewing a photo, downloading a published one and every action on a managed newsroom laptop are untouched, so the policy interrupts only the requests it was written for. A policy that applied to "all photo actions" would have asked Omar for a passkey every time he opened the library, and people who are interrupted for no reason learn to click through every prompt.

The requires line is what distinguishes conditional access from an ordinary deny rule. The policy does not answer "no". It answers "not yet, and here is what would change the answer". That only helps if the answer can travel from the photo API back to the application, and from the application to the authorization server that can collect the missing evidence.

The API says what is missing

At 15:00 UTC, Omar selects Download in the Gazette's photo desk app. The app sends the request with the access token it received when Omar signed in that morning, with his password, at 08:10. The photo API validates the token, asks the decision service, and gets back a denial whose reason is the unmet requirement: the sign-in is too old and was not made with a passkey.

A plain 403 would leave the app with nothing to do. Instead, the API answers with the step-up authentication challenge defined in RFC 9470, which extends the bearer token challenge from RFC 6750 with a new error code and two parameters:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="insufficient_user_authentication",
  error_description="A passkey sign-in within 15 minutes is required",
  acr_values="urn:photos:acr:passkey",
  max_age="900"

The error insufficient_user_authentication says the token is valid but the authentication behind it does not meet this resource's requirement. acr_values names the authentication level the API needs, using a value the Gazette's authorization server publishes for a passkey sign-in. max_age says how old, in seconds, that sign-in may be. The status is 401 rather than 403 because the remedy is a new token, exactly as for an expired one.

To decide, the API needed to know how and when Omar signed in. It reads that from two claims the authorization server put in the access token, or returns from introspection for an opaque token. This is the payload of Omar's morning token:

{
  "iss": "https://auth.photos.example",
  "sub": "user-1187",
  "aud": "https://api.photos.example",
  "client_id": "photo-desk",
  "scope": "photos.read photos.download",
  "acr": "urn:photos:acr:password",
  "auth_time": 1781424600,
  "iat": 1781448730,
  "exp": 1781449630
}

acr records the authentication level the sign-in met, and auth_time records when it happened, as seconds since 1970: 08:10 UTC on 14 June. The token itself was issued at 14:52, when the app last refreshed, which is why iat is recent. Refreshing a token does not refresh the sign-in behind it, so auth_time still says 08:10, and the API compares that value, not iat, with the 15 minutes the policy allows.

Asking the authorization server for more

The app cannot satisfy the challenge itself. Only the authorization server can collect a new sign-in and record it in a token, so the app sends Omar's browser back with an ordinary authorization request that carries the API's two values:

https://auth.photos.example/authorize
  ?response_type=code
  &client_id=photo-desk
  &redirect_uri=https%3A%2F%2Fdesk.photos.example%2Fcallback
  &scope=photos.read%20photos.download
  &state=Vq3x9KtLm2
  &code_challenge=Ys0nH8-AvE2ZqT0R4xwK9c1bJ6pLmUe3dGfQ7iNo5aw
  &code_challenge_method=S256
  &acr_values=urn%3Aphotos%3Aacr%3Apasskey
  &max_age=900

Both parameters come from OpenID Connect, where Requesting stronger authentication and Session age and reauthentication explain them in full, and RFC 9470 reuses them for OAuth requests. max_age=900 means Omar's 08:10 sign-in is too old to reuse, so the authorization server must authenticate him again. acr_values asks for the passkey level. Omar touches his passkey, the server issues a code, the app redeems it, and the new access token carries "acr": "urn:photos:acr:passkey" and an auth_time of 15:03:40. The app repeats the download with that token, and the photo API allows it.

The API names the missing evidence, the authorization server collects it, and the same request succeeds with a token that records it.

The authorization server treats acr_values as a request, not an order. If it cannot or will not perform a passkey sign-in, it may still issue a token with a lower level in acr. That is why the photo API checks the claim on every token, not just the first one it challenged, and why a client that must have a level can ask for acr as an essential claim in the claims parameter. A provider that cannot meet an essential requirement then returns the error unmet_authentication_requirements instead of a token. Either way, the decision belongs to the resource: it accepts what the token proves, not what the app says happened.

Two things stay fixed through all of this. The new token is a new token, so Omar's morning token remains as weak as it was and is still challenged if anything presents it. And the step-up proves only what the policy asked for. A fresh passkey sign-in on an unmanaged laptop satisfies the café rule, but it says nothing new about the laptop. When the decision service also reports a high risk score, as it did for the third context in the earlier lesson, asking for another sign-in would add no new evidence, and the policy denies instead. The later lessons on step-up for APIs cover the protocol's finer points, such as challenges that combine several levels.

Combining policies without surprises

The Gazette soon has several policies. One blocks downloads of any photo under legal hold. One requires a managed device for anyone in the Finance team. One asks contractors to sign in again every eight hours. A single request can match several of them, so the rule for combining them matters as much as any one policy.

Conditional access systems usually combine in the strictest direction: every matching policy applies, any block wins, and every requirement must be met, so a request that matches both a passkey policy and a managed-device policy needs both. The Gazette writes that down, because it is the same choice as the combining algorithm in Evaluating a policy, and an engine that let the first matching permit win would let a broad "picture editors may download" policy override the legal-hold block.

Some requests cannot step up at all. The overnight job that builds thumbnails runs with its own client credentials and has no person to touch a passkey. A policy that requires an interactive sign-in must either exclude such clients deliberately, with conditions of their own, or refuse them. A client that fails a user-authentication condition must never be able to satisfy it by asserting an acr value of its own.

Exceptions deserve the same care as policies. Each one names who it covers, who approved it, and when it ends, and it shows up in reviews. The emergency accounts that keep the library manageable when the authorization server is down are excluded from the passkey policy on purpose, and watched more closely because of it, a trade-off Temporary, privileged, and emergency access explores.

Before switching a new policy on, the Gazette runs it in report-only mode for a week: the decision service evaluates it on every request and records what it would have done, while the policies already in force still decide. The report shows who would have been challenged and who would have been blocked, which catches the policy that accidentally covered every preview. Report-only is measurement, not protection, and a week of good reports still ends with the real test: switching it on and sending the request straight to the photo API.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

Omar's token was issued two minutes ago, but its auth_time is 08:10. The policy needs a sign-in within 15 minutes. What should the API do? 1 of 3

Choose one answer.

The app sent acr_values for the passkey level, but the new token's acr names the password level. What should the photo API do? 2 of 3

Choose one answer.

A photo under legal hold is blocked from download. Omar's request also matches a broad policy, "picture editors may download". How should the Gazette combine them? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity