
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/">
    <channel>
        <title><![CDATA[ The Cloudflare Blog ]]></title>
        <description><![CDATA[ Get the latest news on how products at Cloudflare are built, technologies used, and join the teams helping to build a better Internet. ]]></description>
        <link>https://blog.cloudflare.com</link>
        <atom:link href="https://blog.cloudflare.com/" rel="self" type="application/rss+xml"/>
        <language>en-us</language>
        <image>
            <url>https://blog.cloudflare.com/favicon.png</url>
            <title>The Cloudflare Blog</title>
            <link>https://blog.cloudflare.com</link>
        </image>
        <lastBuildDate>Wed, 24 Jun 2026 21:04:37 GMT</lastBuildDate>
        <item>
            <title><![CDATA[Unlocking the Cloudflare app ecosystem with OAuth for all]]></title>
            <link>https://blog.cloudflare.com/oauth-for-all/</link>
            <pubDate>Wed, 24 Jun 2026 06:00:00 GMT</pubDate>
            <description><![CDATA[ Self-Managed OAuth is now available to all developers on Cloudflare. Here's how we executed a zero-downtime migration of our core OAuth engine to make it happen. ]]></description>
            <content:encoded><![CDATA[ <p>Cloudflare provides services that help run 20% of the web, but we don’t do it alone. Developers on our platform use a myriad of tools and services from other companies too. Cloudflare provides a rich API for our platform that enables developers to create automations, CI/CD, and integrations that glue together the various parts of their infrastructure. Earlier this month, we announced <a href="https://developers.cloudflare.com/changelog/post/2026-06-03-public-oauth-clients/"><u>self-managed OAuth</u></a>, making it easier for customers to create and manage their own OAuth clients for delegated access to the Cloudflare API.</p><p>Cloudflare isn’t new to OAuth. If you’ve used Wrangler, or used integrations from partners like PlanetScale, then you’ve already used it. However, until now, third-party OAuth was only available through a small number of manually onboarded integrations, and was not available to developers more broadly. That meant developers building their own integrations had to rely on API tokens, which are harder to manage and a poor fit for many delegated application flows. </p><p>Over the last year, we onboarded a growing number of early partners while improving the consent, revocation, and security model behind Cloudflare OAuth. But as our Developer Platform grew and agentic tools drove demand for delegated access, it became clear that opening up OAuth to all customers was critical to the success of our platform. </p><p>With self-managed OAuth, developers can now offer a standard OAuth flow where customers grant scoped access directly, making it easier to build SaaS integrations, internal developer platforms, and agentic tools while giving users clearer consent, easier revocation, and more control over what an application can do.</p>
    <div>
      <h2>Scaling the ecosystem securely</h2>
      <a href="#scaling-the-ecosystem-securely">
        
      </a>
    </div>
    <p>While our earlier OAuth solution was sufficient for a small number of carefully managed partners, we realized that our permissions model, our consent experience, and our ways of mitigating potential abuse vectors were not mature enough. </p><p>Earlier this year we <a href="https://blog.cloudflare.com/improved-developer-security/#improving-the-oauth-consent-experience"><u>updated our consent experience</u></a> to make it clearer which application is requesting access, and what permissions it will receive. We also added revocation to the dashboard so developers can easily control which applications have access to their data, and made app ownership more visible to prevent OAuth phishing attacks. </p><p>Opening self-managed OAuth to all customers also required major upgrades to our underlying OAuth engine. This process required a large amount of planning to do with minimal user interruption, while also ensuring data stability and security.</p>
    <div>
      <h2>Planning the upgrade to our OAuth engine</h2>
      <a href="#planning-the-upgrade-to-our-oauth-engine">
        
      </a>
    </div>
    <p>Years ago, we deployed <a href="https://github.com/ory/hydra"><u>Hydra</u></a>, an open-source OAuth engine, to power Cloudflare OAuth under the hood. That deployment served us well when usage was limited, but as the developer platform grew and agentic workflows became more common, it became clear that we needed a major upgrade to unlock new capabilities and improve performance. </p><p>As we planned the upgrade, we decided to do two smaller sequential upgrades rather than doing one large upgrade.  First, we would move to the latest 1.X release, evaluate any behavior or performance changes, and then proceed with the 2.X upgrade.</p><p>During our upgrade planning, it became clear that even the 1.X upgrade would<i> </i>still impact customers because the Hydra database required extensive schema migrations that:</p><ol><li><p>Created indexes in a manner that would claim an exclusive lock on critical tables, preventing active users from performing important OAuth operations </p></li><li><p>Added columns to critical tables, and moved other columns to new tables</p></li></ol><p>There was also a quirk in the version of Hydra we were using in which the SDK would perform SELECT * operations, causing deserialization issues with the schema changes.</p><p>To prevent user impact, we rewrote the SQL migrations to use features such as CREATE INDEX CONCURRENTLY, and built a custom version of Hydra which selected explicit columns rather than SELECT *.</p><p>With the latest 1.X upgrade planned out, we now needed to create a plan for the even larger 2.X upgrade. We identified three potential options, and weighed the benefits and drawbacks of each one. Doing an in-place upgrade was not going to work for us, due to the sheer amount of schema changes the major version bump brought with it. We decided that a blue-green strategy would work, but there was more that needed to be done than simply flipping a switch to start using the new version. The upgrade and migration process would take multiple hours, and we needed the system to continue functioning correctly in that time window.</p><p>The first blue-green option would involve disabling writes to the database, preventing any new authorizations from occurring. This means they would not be lost in the transition, but it also meant that nobody would be able to use existing OAuth apps unless they already had a valid credential. It also presented another large problem: if users needed to revoke access from an application for any reason, it would not be possible while the upgrade was being performed.</p><p>To combat these issues, we came up with a way to leave writes to the database enabled, at the cost of losing some of them in the switch to the green version. The first thing to solve was minimizing the number of writes for new tokens. There was an operational lever we pulled: increasing the expiry time of tokens to multiple hours. This would allow apps that received new tokens before the upgrade to continue using them without needing to refresh.</p><p>With reducing writes solved, we needed to come up with a way to not lose any revocations our users performed during the upgrade window. To do this, we created a queue system (using <a href="https://developers.cloudflare.com/queues/"><u>Cloudflare Queues</u></a>!) which, after a revocation event, would have a record written into the queue with information about that revocation. This would allow us to drain the queue with the database flipped to the green version, replaying all revocation events that took place in the time window in which they would have been lost. This was critical to get right, otherwise applications that users had revoked would inadvertently have their access restored.</p>
    <div>
      <h2>Executing the upgrade</h2>
      <a href="#executing-the-upgrade">
        
      </a>
    </div>
    
    <div>
      <h3>Upgrading to 1.X</h3>
      <a href="#upgrading-to-1-x">
        
      </a>
    </div>
    <p>From an operational point of view, our first upgrade to the last 1.X release went off without any hitches. Our custom database migrations ran faster than we expected, with no user impact. We had to do a hard cutover to the new version because the old version was unable to introspect tokens that were created by the newer version.</p><p>After the cutover, we saw an increase in refresh token errors that we had not seen before. This ended up being due to stricter refresh invalidation behaviors in the new version; if a refresh token was reused, Hydra would invalidate the whole access and refresh token chain. This is problematic for Wrangler and MCP clients. These clients both have a high request volume, and a single reused refresh token would invalidate the entire session.</p><p>We mitigated this by adding refresh token coalescing behavior to our Worker which routes OAuth traffic to the correct destination. This allowed us to briefly cache the refresh token request before it reached Hydra, so that if we detected a retry we could short-circuit the request and respond without invalidating the tokens. Fortunately, 2.X versions of Hydra have a configurable “refresh token grace period”, which resolves this by allowing a refresh token to be retried for a period of time without invalidating the whole chain.</p>
    <div>
      <h3>Upgrading to 2.X</h3>
      <a href="#upgrading-to-2-x">
        
      </a>
    </div>
    <p>Since multiple hours of high user-facing impact would not be acceptable, we had our blue-green upgrade strategy set. At a high level, this sounds simple; the migrations would run on a copy of our production database, and then cut over along with the new Hydra version after they complete. In reality, there were a <i>lot </i>more moving parts:</p><ul><li><p>Enable revocation replay capture queue</p></li><li><p>Copy and restore our database to the new target</p></li><li><p>Targeted data cleanup — existing data violated some new constraints introduced in the newer versions, which could prevent migrations from succeeding</p></li><li><p>Perform cutovers on the Hydra service along with two additional critical internal systems simultaneously to prevent any errors</p></li><li><p>Post-cutover monitoring and validation</p></li></ul>
          <figure>
          <img src="https://cf-assets.www.cloudflare.com/zkvhlag99gkb/tbiQb2wX9zyyC2n6cOMmv/706bacb728d5abef09117c3893ec288d/hydra_upgrade_diagram.png" />
          </figure><p>We chose an upgrade window when Hydra had the lowest request volume per second to minimize lost token writes. Other than some timeout tuning, our production migrations ran well against the new database: the net runtime in production was approximately three hours. After the migrations completed, we carefully rolled out the new version of the Hydra service, along with two additional system configs to flip our systems to use the new SDK version.</p><p>Shortly after cutting traffic over, we observed that a data cleanup job in our authorization service (which relies on the Hydra consent session API) was being overeager in its purging of OAuth policy data. After investigation, we discovered that there was an issue in one of the Hydra migrations that corrupted the state of certain valid OAuth sessions, which resulted in the migration marking them as invalid. The valid sessions being corrupted caused a disagreement between Hydra and our authorization service, manifesting as an increase in 403s. To mitigate this, we did data restorations and began work on improvements for OAuth authorization behaviors to remove reliance on static policy data.</p><p>Beyond the data cleanup issue, there were some additional small fixes more driven by specific client behaviors which we landed quickly. </p><p>With the Hydra version upgrade complete, OAuth traffic has remained stable with improved system performance and reliability for our customers. It also brought production onto the same foundation our newer OAuth APIs had already been validated against in staging, clearing the way for our <a href="https://developers.cloudflare.com/changelog/post/2026-06-03-public-oauth-clients/"><u>self-managed OAuth release on June 3</u></a>. </p>
    <div>
      <h2>Performance improvements</h2>
      <a href="#performance-improvements">
        
      </a>
    </div>
    <p>After completing a large upgrade like this, it is always rewarding and illuminating to look at some broad metrics about the impact. We gathered additional metrics during the database migrations, and observed considerable performance improvements after the upgrade was complete.</p>
    <div>
      <h3>Database</h3>
      <a href="#database">
        
      </a>
    </div>
    
<table><colgroup>
<col></col>
<col></col>
</colgroup>
<thead>
  <tr>
    <th><span>Metric</span></th>
    <th><span>Approx. Value</span></th>
  </tr></thead>
<tbody>
  <tr>
    <td><span>Rows updated</span></td>
    <td><span>132.5M</span></td>
  </tr>
  <tr>
    <td><span>Rows inserted</span></td>
    <td><span>114.7M</span></td>
  </tr>
  <tr>
    <td><span>Temp bytes</span></td>
    <td><span>136.97GB</span></td>
  </tr>
  <tr>
    <td><span>Transaction commits</span></td>
    <td><span>22.2k</span></td>
  </tr>
</tbody></table>
    <div>
      <h3>Hydra performance</h3>
      <a href="#hydra-performance">
        
      </a>
    </div>
    
<table><colgroup>
<col></col>
<col></col>
<col></col>
<col></col>
</colgroup>
<thead>
  <tr>
    <th><span>Metric (avg)</span></th>
    <th><span>Before</span></th>
    <th><span>After</span></th>
    <th><span>Change</span></th>
  </tr></thead>
<tbody>
  <tr>
    <td><span>API P95</span></td>
    <td><span>185ms</span></td>
    <td><span>101ms</span></td>
    <td><span>-45%</span></td>
  </tr>
  <tr>
    <td><span>RSS memory</span></td>
    <td><span>888MB</span></td>
    <td><span>763MB</span></td>
    <td><span>-14%</span></td>
  </tr>
  <tr>
    <td><span>Go heap alloc</span></td>
    <td><span>449MB</span></td>
    <td><span>271MB</span></td>
    <td><span>-40%</span></td>
  </tr>
  <tr>
    <td><span>Goroutines</span></td>
    <td><span>4015</span></td>
    <td><span>3076</span></td>
    <td><span>-23%</span></td>
  </tr>
  <tr>
    <td><span>CPU</span></td>
    <td><span>1.07 cores</span></td>
    <td><span>0.67 cores</span></td>
    <td><span>-37%</span></td>
  </tr>
</tbody></table>
    <div>
      <h2>Self-managed OAuth for all</h2>
      <a href="#self-managed-oauth-for-all">
        
      </a>
    </div>
    <p>Opening up OAuth to all customers is an important step toward a broader Cloudflare app ecosystem. Today, any Cloudflare customer can create their own OAuth applications and build integrations on top of Cloudflare. We’re extremely excited to launch Cloudflare self-managed OAuth for all. </p><p>To get started, take a look at our <a href="https://developers.cloudflare.com/fundamentals/oauth/"><u>documentation</u></a> or jump straight to the OAuth apps page in the <a href="https://dash.cloudflare.com/?to=/:account/oauth-clients"><u>dashboard</u></a> and create your first OAuth app.</p> ]]></content:encoded>
            <category><![CDATA[Developers]]></category>
            <category><![CDATA[API]]></category>
            <category><![CDATA[Security]]></category>
            <category><![CDATA[OAuth]]></category>
            <category><![CDATA[Developer Platform]]></category>
            <category><![CDATA[Agents]]></category>
            <category><![CDATA[Product News]]></category>
            <category><![CDATA[Cloudflare Media Platform]]></category>
            <category><![CDATA[Identity]]></category>
            <guid isPermaLink="false">77AgsHNNnpUDvP0Z6gqgp6</guid>
            <dc:creator>Sam Cabell</dc:creator>
            <dc:creator>Mike Escalante</dc:creator>
            <dc:creator>Adam Bouhmad</dc:creator>
            <dc:creator>Nick Comer</dc:creator>
        </item>
    </channel>
</rss>