Skip to content

feat(worker): bespoke OAuth with device authorization grant (RFC 8628)#203

Merged
liplus-lin-lay merged 1 commit into
mainfrom
198-oauth-device-flow
Apr 20, 2026
Merged

feat(worker): bespoke OAuth with device authorization grant (RFC 8628)#203
liplus-lin-lay merged 1 commit into
mainfrom
198-oauth-device-flow

Conversation

@liplus-lin-lay
Copy link
Copy Markdown
Member

Closes #199

Worker 側の OAuth 実装を @cloudflare/workers-oauth-provider から自前の Device Authorization Grant (RFC 8628) 実装へ全面切り替え。#195 の chronic auth loop を構造的に根絶するための Step 2 実装。

主な変更:

  • worker/src/oauth.ts を全面書き換え。RFC 8414 metadata / RFC 7591 dynamic registration / RFC 8628 §3.1 device_authorization / §3.4 device_code grant / §3.5 準拠の polling error (authorization_pending / slow_down / access_denied / expired_token) / refresh_token rotation / 独自 Bearer token 検証 middleware を提供。
  • worker/src/oauth-store.ts を新規追加。OAuth KV schema helper (client:* / device:* / user_code:* / token:* / refresh:* / grant:*)。旧 provider の opaque key format は撤去。
  • worker/src/index.ts から OAuthProvider wrapper を撤去し、独自 router へ移行。/oauth/authorize/oauth/callback は HTTP 410 Gone。
  • @cloudflare/workers-oauth-provider dependency を削除(package.json + package-lock.json)。
  • docs/0-requirements.md.ja.md に F7 (OAuth) セクションを追加、target files 表を更新。

Scope note: issue で「worker/src/store.ts (KV schema 再設計)」とあったが、既存 store.ts は WebhookStore DO 専用で OAuth とは無関係のため、OAuth KV helper は責務分離のため新規 oauth-store.ts に分離しました。WebhookStore DO は無変更。

ローカル検証: npx wrangler deploy --dry-run 成功。

Part of #198

Worker 側の OAuth 実装を @cloudflare/workers-oauth-provider から
自前の Device Authorization Grant (RFC 8628) 実装へ全面切り替え。
#195 の chronic auth loop の構造的根絶が目的(#198 Step 2)。

主な変更:

- worker/src/oauth.ts を全面書き換え。RFC 8414 metadata /
  RFC 7591 dynamic registration / RFC 8628 §3.1 device_authorization /
  §3.4 device_code grant / §3.5 準拠の polling error (authorization_pending /
  slow_down / access_denied / expired_token) / refresh_token rotation /
  独自 Bearer token 検証 middleware を提供。
- worker/src/oauth-store.ts を新規追加。OAuth KV schema helper:
  client:* / device:* / user_code:* / token:* / refresh:* / grant:*。
  旧 provider の opaque key format は撤去。
- worker/src/index.ts から OAuthProvider wrapper を撤去し、独自 router へ移行。
  /oauth/authorize と /oauth/callback は HTTP 410 Gone。
- @cloudflare/workers-oauth-provider dependency を package.json と
  package-lock.json から削除。
- docs/0-requirements.md と .ja.md に F7 (OAuth) セクションを追加。
  target files 表に oauth.ts / oauth-store.ts を追記。

注記: issue で「worker/src/store.ts (KV schema 再設計)」とあったが、
既存 store.ts は WebhookStore DO 専用のため、OAuth 用 KV helper は
責務分離のため新規 oauth-store.ts に分離した。WebhookStore DO は無変更。

ローカル検証: npx wrangler deploy --dry-run 成功。

Part of #198
Refs #199
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-webhook-mcp f31f0b0 Apr 20 2026, 04:45 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant