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 APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. names what is missing, the authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. 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 passkeyA credential that your phone, computer or password manager creates for one website and keeps for you, unlocked with a fingerprint, face or PIN. Nothing you could type is sent, and it works only for the site it was made for, which helps it resist phishing. 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: denyEach 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 authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. 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 tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. it received when Omar signed in that morning, with his password, at 08:10. The photo API validates the tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret., 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 tokenA token that works for whoever presents it: the API checks that the token is genuine and current, not who is holding it. That is why bearer tokens must be kept from being copied. 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 introspectionA way for an API to ask the authorization server what a token means: whether it is still active and what access it carries. APIs need it when a token is a random string that only the authorization server can interpret. 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.
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.
Try it in the Lab
- Challenge only the action whose condition is unmetRequire two factors for one Photo API operation, see a password-only token challenged there and nowhere else, then return with a stronger sign-in.