Menu
Cloudflare Blog·August 20, 2026

Implementing Task-Based OAuth Consent for Granular Access Control

Cloudflare introduced task-based OAuth consent, allowing users to grant a narrower subset of an application's requested permissions. This feature improves security and user control by enabling developers to mark specific scopes as optional, moving beyond an all-or-nothing authorization model. Architecturally, it involves the authorization server evaluating requested scopes against configured optional scopes and issuing access tokens with only the explicitly consented permissions.

Read original on Cloudflare Blog

OAuth enables delegated access, allowing applications to act on a user's behalf without direct credential handling. Historically, Cloudflare's OAuth consent was an "all-or-nothing" model, presenting a challenge as permission granularity increased. While clients could request a subset of their configured scopes, users on the consent screen could not further narrow that request. This led to situations where users either had to approve overly broad access or deny the application entirely, impacting security and user experience, especially for applications like Management Control Plane (MCP) servers that might request a wide array of theoretical permissions.

Introduction of Task-Based Scope Customization

Cloudflare's new OAuth scope customization allows client owners to mark specific scopes as optional during client configuration. This gives users the ability to deselect optional scopes at authorization time, granting a more specific, narrower set of permissions. This architectural change aligns with the OAuth specification's allowance for authorization servers to issue narrower scope grants than initially requested, integrating cleanly with existing applications.

ℹ️

Key Functionality

Developers can designate scopes as required or optional. At authorization, users can deselect optional scopes. The system evaluates required and optional scopes only against the scopes requested in the *current* authorization flow, ensuring the consent screen remains focused on the task at hand. If no optional scopes are requested, the traditional consent flow is maintained.

Implications for Developers and System Design

When a user deselects optional scopes, the generated access token will only contain the scopes they consented to. This requires developers to explicitly check the granted scope set after exchanging the authorization code, rather than assuming the full requested set was approved. Applications should be designed to handle these partial grants gracefully, adapting their functionality based on the permissions received. This promotes a more secure architecture where applications operate with the least privilege necessary.

json
{
  "client_id": "your_client_id",
  "scopes": [
    {"name": "user-details.read", "optional": false},
    {"name": "workers-scripts.write", "optional": false},
    {"name": "workers-kv-storage.write", "optional": true},
    {"name": "zone.read", "optional": true}
  ]
}
OAuthAuthorizationAccess ControlScopesAPI SecurityUser ExperienceCloudflareDelegated Access

Comments

Loading comments...