Cloudflare、すべてのアプリエコシステムでOAuthを解放
Cloudflare は、開発者プラットフォームの拡大とアジェンティックツールの需要に対応するため、従来の限定的な OAuth からすべての顧客が利用可能なセルフマネージド OAuth エコシステムを正式に解放した。
キーポイント
セルフマネージド OAuth の一般公開
以前は手動オンボーディングが必要だった第三者 OAuth を、すべての開発者が利用可能にし、標準的な OAuth フローによるスコープ付きアクセス付与を可能にした。
セキュリティと同意モデルの強化
アプリケーションの識別表示の明確化、ダッシュボードからの権限取り消し機能の追加、およびフィッシング攻撃防止のためのアプリ所有権の可視化など、セキュリティ基盤を大幅にアップグレードした。
OAuth エンジンの大規模刷新
以前のオープンソースエンジン「Hydra」から、スケーラビリティとパフォーマンスを向上させた新エンジンへ移行し、最小限のユーザー中断でデータ安定性とセキュリティを確保した。
アジェンティックツールへの対応
自律型ツールの台頭に伴い、API トークンの管理難易度が高い課題に対し、より適切な委任アクセス(delegated access)の仕組みを提供し、SaaS 統合や内部開発プラットフォームの構築を容易にした。
非同期インデックス作成と明示的カラム選択による移行リスクの回避
ユーザーへの影響を避けるため、排他ロックを防ぐ「CREATE INDEX CONCURRENTLY」を採用し、SDK の「SELECT *」問題を解消するためにカスタム版 Hydra で明示的なカラム指定を行うように SQL 移行スクリプトを書き直しました。
ブルーグリーン戦略における書き込みの継続とトークン有効期間の延長
アップグレード中にシステム機能を維持するため、データベースへの書き込みを停止せず、代わりにトークンの有効期限を数時間に延長することで、移行前のトークンが使用可能となり、新規トークン発行時の書き込み数を最小化しました。
大規模バージョンアップにおけるブルーグリーン戦略の複雑性
大規模なスキーマ変更のため在来型アップグレードは不可能であり、移行に数時間を要する中、アクセス権の取り消し機能や既存 OAuth アプリの利用継続を維持するためには単なる切り替え以上の対策が必要でした。
影響分析・編集コメントを表示
影響分析
この発表は、Cloudflare を中心としたインフラストラクチャエコシステムにおいて、セキュリティと利便性を両立する標準的な認証フローを確立した点で重要です。特に、自律型 AI ツール(アジェンティックツール)の普及に伴い、従来の API トークン管理では対応しきれない委任アクセスの需要に応えることで、開発者プラットフォームの競争力を強化します。
編集コメント
API トークンの管理難易度という長年の課題に対し、OAuth という標準プロトコルを一般公開することで解決を図った点は、開発者体験の向上に直結する重要な一歩です。特に自律型ツールの台頭を見据えた基盤強化は、今後のクラウドエコシステムにおけるセキュリティ基準を示唆しています。
Cloudflare はウェブの 20% を支えるサービスを提供していますが、それは単独で行っているわけではありません。当社のプラットフォーム上の開発者もまた、他社製の多様なツールやサービスを利用しています。Cloudflare は、開発者がインフラストラクチャのさまざまな部分を結びつける自動化、CI/CD(継続的インテグレーション・継続的デリバリー)、および統合を作成できる豊富な API を提供しています。先月、自己管理型 OAuth を発表し、顧客が Cloudflare API への委任アクセスのために独自の OAuth クライアントをより簡単に作成・管理できるようにしました。
Cloudflare が OAuth に不慣れなわけではありません。Wrangler を使用したことがある方、あるいは PlanetScale などのパートナー製統合を利用したことがある方は、すでに OAuth を利用していることになります。しかし、これまで第三者による OAuth は、手動でオンボーディングされた少数の統合を通じてのみ利用可能であり、より広範な開発者には提供されていませんでした。つまり、独自の統合を構築する開発者は API トークンに頼らざるを得ず、これは管理が難しく、多くの委任アプリケーションフローには適していませんでした。
過去 1 年間、Cloudflare OAuth の背後にある同意、取り消し、セキュリティモデルを改善しながら、早期パートナーの数を着実に増やしてきました。しかし、当社の開発者プラットフォームが成長し、エージェント型ツールによる委任アクセスへの需要が高まるにつれ、すべての顧客に OAuth を開放することがプラットフォームの成功にとって不可欠であることが明確になりました。
セルフマネージド OAuth を利用することで、開発者は顧客がスコープ付きのアクセス権限を直接付与する標準的な OAuth フローを提供できるようになりました。これにより、SaaS 統合や内部向け開発者プラットフォーム、エージェント型ツールの構築が容易になり、ユーザーは同意内容が明確になり、権限の取り消しが簡単になり、アプリケーションが行えることの制御も強化されます。
エコシステムの安全な拡大
以前の OAuth ソリューションは、少数の慎重に管理されたパートナーにとっては十分でしたが、権限モデルや同意体験、潜在的な悪用ベクトルを緩和する方法がまだ成熟していないことを認識しました。
今年初めに、どのアプリケーションがアクセスを要求しているのか、そしてどのような権限が付与されるのかをより明確にするよう、同意の体験を更新しました。また、ダッシュボードに権限取り消し機能を追加し、開発者がデータへのアクセスを持つアプリケーションを簡単に制御できるようにしました。さらに、OAuth フィッシング攻撃を防ぐために、アプリの所有権をより可視化しています。
セルフマネージド OAuth をすべての顧客に開放するには、基盤となる OAuth エンジンの大規模なアップグレードが必要でした。このプロセスでは、ユーザーへの中断を最小限に抑えつつ、データの安定性とセキュリティを確保するために、多大な計画が必要でした。
OAuth エンジンのアップグレード計画
数年前、私たちはクラウドフローの OAuth を裏側で支えるために、オープンソースの OAuth エンジンである Hydra を展開しました。利用が限られていた頃はこの展開が私たちにとってよく機能していましたが、開発者プラットフォームが成長し、エージェント型ワークフローがより一般的になるにつれ、新たな機能を解放しパフォーマンスを向上させるためには大規模なアップグレードが必要であることが明確になりました。
アップグレードの計画を進めるにあたり、私たちは一度に大規模なアップグレードを行うのではなく、2 つの小さな段階的なアップグレードを順次行うことを決定しました。まず、最新の 1.X リリースへ移行し、動作やパフォーマンスの変化を評価した上で、その後 2.X アップグレードへと進む方針でした。
アップグレード計画を進める中で、1.X アップグレードであっても顧客に影響を与えることが明らかになりました。その理由は、Hydra のデータベースには広範なスキーママイグレーションが必要であり、それが以下の問題を引き起こすためです:
- 重要なテーブルに対して排他ロックを要求する形でインデックスを作成し、アクティブなユーザーが重要な OAuth 操作を実行できなくしてしまうこと
- 重要なテーブルに列を追加し、他の列を新しいテーブルへ移動させること
また、私たちが使用していた Hydra のバージョンには特有の癖があり、SDK が SELECT * 演算を実行することで、スキーマ変更との間でシリアライズ/デシリアライズの不具合が発生していました。
ユーザーへの影響を防ぐため、私たちは SQL マイグレーションを再構築し、CREATE INDEX CONCURRENTLY などの機能を利用する形に変更しました。また、SELECT * の代わりに明示的な列を選択するカスタム版の Hydra を構築しました。
最新の 1.X アップグレードの計画が整ったことで、今度はより大規模な 2.X アップグレードのための計画を作成する必要がありました。3 つの潜在的な選択肢を特定し、それぞれの実施におけるメリットとデメリットを検討しました。メジャーバージョンのアップグレードに伴う膨大なスキーマ変更のため、インプレースアップグレードでは対応できないことが判明しました。ブルーグリーン戦略を採用することで解決できると判断しましたが、単にスイッチを切り替えて新バージョンを使用開始するだけでは不十分でした。アップグレードおよび移行プロセスには複数の時間が必要であり、その間もシステムが正しく機能し続ける必要があります。
最初のブルーグリーンの選択肢では、データベースへの書き込みを無効化し、新しい認証の発生を防ぐことを想定していました。これにより移行中に認証情報が失われることはありませんが、既存の OAuth アプリケーション(OAuth apps)を利用できるのは、すでに有効な資格情報を保持しているユーザーに限られることになります。また、別の大きな問題も浮上しました:いかなる理由からでもアプリケーションからのアクセス権限を取消す必要がある場合、アップグレード実施中はそれが不可能になるのです。
これらの課題に対処するため、データベースへの書き込みを有効に保ちつつ、グリーンバージョンへ切り替える際に一部の書き込みが失われるという代償を払う方法を考案しました。まず解決すべきは、新しいトークンに対する書き込み数を最小化することでした。そこで運用上のレバーとして、トークンの有効期限を数時間に延長するという措置を講じました。これにより、アップグレード前に新しいトークンを取得したアプリが、再更新の必要なく引き続き使用できるようになります。
書き込み数の削減という課題は解決しましたが、アップグレード期間中にユーザーが行った取り消し(revocation)を一切失わない方法も考案する必要がありました。そのために、Cloudflare Queues! を利用したキューシステムを作成しました。このシステムでは、取り消しイベントが発生すると、その取り消しに関する情報が記録されたレコードがキューに書き込まれます。これにより、データベースをグリーンバージョンに切り替えた後にキューを処理(drain)し、本来失われていたはずの期間中に発生したすべての取り消しイベントを再生成することが可能になります。これは極めて重要で、正しく実装されなければ、ユーザーが取り消したアプリケーションに対して誤ってアクセス権限が復元されてしまう恐れがあります。
アップグレードの実行
1.X へのアップグレード
運用の観点から、最後の 1.X リリースに対する最初のアップグレードは、何の問題もなく完了しました。カスタムのデータベースマイグレーションは予想よりも高速に実行され、ユーザーへの影響はありませんでした。新しいバージョンによって作成されたトークンを古いバージョンが内部参照できないため、新バージョンへのハードカットオーバーを実施する必要がありました。
カットオーバー後、以前には見られなかったリフレッシュトークンのエラーが増加しました。これは、新バージョンでより厳格なリフレッシュ無効化の挙動となったことが原因でした。リフレッシュトークンが再利用されると、Hydra はアクセストークンとリフレッシュトークンのチェーン全体を無効化してしまいます。これは Wrangler や MCP クライアントにとって問題となります。これらのクライアントは高いリクエストボリュームを持っており、1 つのリフレッシュトークンを再利用するだけでセッション全体が無効化されてしまうからです。
この問題は、OAuth トラフィックを正しい宛先にルーティングする Worker にリフレッシュトークンの統合(coalescing)機能を追加することで緩和しました。これにより、Hydra に到達する前にリフレッシュトークン要求を一時的にキャッシュできるようになり、再試行を検知した場合は要求を短絡して応答し、トークンを無効化せずに済むようになりました。幸いにも、Hydra の 2.X バージョンには設定可能な「リフレッシュトークンの猶予期間(grace period)」が用意されており、これにより一定の期間中はリフレッシュトークンの再試行が可能となり、チェーン全体の無効化を防ぐことができます。
2.X へのアップグレード
ユーザーへの影響が数時間に及ぶことは許容できないため、ブルーグリーンアップグレード戦略を策定しました。高レベルではこれはシンプルに聞こえます。つまり、移行は本番データベースのコピー上で実行され、完了後に新しい Hydra バージョンとともに切り替えられるというものです。しかし実際には、多くの要素が絡み合っていました。
失効再試行キャプチャキューの有効化
データベースを新ターゲットへコピーして復元する
対象となるデータクリーンアップ — 既存のデータは、新しいバージョンで導入された一部の制約に違反しており、これが移行の成功を妨げる可能性があります
エラーを防ぐため、Hydra サービスと2 つの追加の重要な内部システムに対して同時に切り替えを実行する
切り替え後の監視と検証
image
トークン書き込みの損失を最小限に抑えるため、Hydra の 1 秒あたりのリクエスト量が最も少なくなるアップグレードウィンドウを選択しました。タイムアウト調整を除けば、本番環境での移行は新しいデータベースに対して順調に進みました。本番環境での総実行時間は約 3 時間でした。移行完了後、慎重に新しい Hydra サービスバージョンをロールアウトし、2 つの追加システム設定も同時に適用して、システムが新しい SDK バージョンを使用するように切り替えました。
トラフィックの切り替え直後、認証サービス(Hydra の同意セッション API に依存しています)内のデータクリーンアップジョブが OAuth ポリシーデータを過剰に削除していることが判明しました。調査の結果、Hydra のマイグレーションのうちの一つに問題があり、特定の有効な OAuth セッションの状態が破損し、マイグレーションによって無効とマークされていたことが分かりました。この有効なセッションの破損により、Hydra と認証サービスの間に不一致が生じ、403 エラーの増加として現れました。これを緩和するため、データの復元を実施し、静的ポリシーデータへの依存を排除する OAuth 認証動作の改善に取り掛かりました。
データクリーンアップの問題以外にも、特定のクライアントの振る舞いに起因する追加的な小規模な修正があり、これらも迅速に適用しました。
Hydra のバージョンアップグレードが完了したことで、OAuth トラフィックは安定し、顧客にとってシステムのパフォーマンスと信頼性が向上しました。また、本番環境を、新しい OAuth API がステージング環境で既に検証済みの基盤と同じものに移行させることに成功し、6 月 3 日のセルフマネージド OAuth リリースへの道を開きました。
パフォーマンスの改善
このような大規模なアップグレードを完了した後、その影響に関する広範なメトリクスを見てみると、常に有意義で洞察に富んだものとなります。データベース移行中に追加のメトリクスを集計したところ、アップグレード完了後に顕著なパフォーマンス向上が確認されました。
データベース
メトリック
概算値
更新行数
1.325 億行
挿入行数
1.147 億行
一時バイト数
136.97GB
トランザクションコミット数
22.2k
Hydra パフォーマンス (Hydra performance)
メトリック(平均)
アップグレード前
アップグレード後
変化率
API P95
185ms
101ms
-45%
RSS メモリ (RSS memory)
888MB
763MB
-14%
Go ヒープ割り当て (Go heap alloc)
449MB
271MB
-40%
ゴルーチン数 (Goroutines)
4015
3076
-23%
CPU
1.07 コア
0.67 コア
-37%
オール顧客向けセルフマネージド OAuth (Self-managed OAuth for all)
OAuth をすべての顧客に開放することは、より広範な Cloudflare アプリエコシステムへの重要な一歩です。今日から、あらゆる Cloudflare の顧客が独自の OAuth アプリケーションを作成し、Cloudflare 上に統合を構築することが可能になりました。Cloudflare オール顧客向けセルフマネージド OAuth のローンチを心から嬉しく思います。
始めるには、当社のドキュメントをご覧くださいか、またはダッシュボードの OAuth アプリページに直接移動して、最初の OAuth アプリを作成してください。
原文を表示
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 self-managed OAuth, making it easier for customers to create and manage their own OAuth clients for delegated access to the Cloudflare API.
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.
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.
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.
Scaling the ecosystem securely
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.
Earlier this year we updated our consent experience 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.
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.
Planning the upgrade to our OAuth engine
Years ago, we deployed Hydra, 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.
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.
During our upgrade planning, it became clear that even the 1.X upgrade would still impact customers because the Hydra database required extensive schema migrations that:
Created indexes in a manner that would claim an exclusive lock on critical tables, preventing active users from performing important OAuth operations
Added columns to critical tables, and moved other columns to new tables
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.
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 *.
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.
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.
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.
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 Cloudflare Queues!) 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.
Executing the upgrade
Upgrading to 1.X
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.
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.
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.
Upgrading to 2.X
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 lot more moving parts:
Enable revocation replay capture queue
Copy and restore our database to the new target
Targeted data cleanup — existing data violated some new constraints introduced in the newer versions, which could prevent migrations from succeeding
Perform cutovers on the Hydra service along with two additional critical internal systems simultaneously to prevent any errors
Post-cutover monitoring and validation
image
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.
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.
Beyond the data cleanup issue, there were some additional small fixes more driven by specific client behaviors which we landed quickly.
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 self-managed OAuth release on June 3.
Performance improvements
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.
Database
Metric
Approx. Value
Rows updated
132.5M
Rows inserted
114.7M
Temp bytes
136.97GB
Transaction commits
22.2k
Hydra performance
Metric (avg)
Before
After
Change
API P95
185ms
101ms
-45%
RSS memory
888MB
763MB
-14%
Go heap alloc
449MB
271MB
-40%
Goroutines
4015
3076
-23%
CPU
1.07 cores
0.67 cores
-37%
Self-managed OAuth for all
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.
To get started, take a look at our documentation or jump straight to the OAuth apps page in the dashboard and create your first OAuth app.
関連記事
Anthropic、Slack 上の Claude を常時監視型のエージェント型 AI コーワーカー「Claude Tag」として再設計
Anthropic は既存の Slack アプリを廃止し、組織内のチャネルやツールにアクセスできる常時稼働型の AI コーワーカー「Claude Tag」を導入すると発表した。この新機能により、ユーザーは@Claudeとタグ付けすることでタスクを委任できるようになる。
エージェント型 AI を活用した自律型ネットワークの構築方法:通信事業者が取り組むべき道筋
NVIDIA は、通信事業者がネットワーク運用や顧客対応において AI を導入している現状を踏まえ、自律化への道のりについて解説しています。
アジェンティック AI に関する一般的な誤解とは何か
KDnuggets は、アジェンティック AI の本質や運用における多くの人が抱いている誤った認識について解説している。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み