Files
OmniRoute/docs/adr/003-oauth-strategy.md
diegosouzapw f44ec7e1f2 feat: complete all 46 tasks — ADRs, eval framework, compliance, a11y, CLI, Playwright specs (Batch B)
T-30 — ADRs:
- 6 ADRs: SQLite, Fallback Strategy, OAuth, JS+JSDoc, Single-Tenant, Translator Registry

T-33 — JSDoc Coverage:
- Full JSDoc on all new modules (100% exported functions documented)

T-35 — Accessibility:
- a11yAudit.js: lightweight WCAG AA checker (aria-label, dialog role, alt text, labels)

T-38 — Password Reset CLI:
- bin/reset-password.mjs: interactive CLI tool for admin password reset

T-39 — Playwright Specs:
- tests/e2e/responsiveSpecs.mjs: viewports (375/768/1280), 4 pages, test matrix

T-42 — Eval Framework:
- evalRunner.js: 4 strategies (exact, contains, regex, custom) + golden set (10 cases)

T-43 — Compliance:
- audit_log table, noLog opt-out per API key, LOG_RETENTION_DAYS cleanup

TASKS.md: 46/46 Concluído 
Tests: 144/144 pass (119 existing + 25 new)
2026-02-14 19:18:02 -03:00

1.7 KiB

ADR-003: OAuth Strategy — Multi-Flow Support

Date: 2025-11-01
Status: Accepted
Deciders: @diegosouzapw

Context

OmniRoute supports 12+ providers, each with different OAuth implementations:

  • Authorization Code + PKCE (Claude, Codex, Gemini, Antigravity, iFlow)
  • Device Code Flow (Qwen, GitHub, Kiro, Kilocode, Kimi-Coding, Cline)
  • Token Import (Cursor — extracted from local SQLite)

A unified approach is needed to manage authentication across all providers.

Decision

Use a base class + strategy pattern:

  1. OAuthService base class (src/lib/oauth/services/oauth.js) — handles common authorization code flow with PKCE
  2. Provider-specific subclasses (e.g., GitHubService, ClaudeService) — override authentication methods
  3. Provider registry (src/lib/oauth/providers.js) — declarative config per provider with flowType, buildAuthUrl, exchangeToken, mapTokens
  4. Constants centralized in src/lib/oauth/constants/oauth.js

Each provider defines:

  • flowType: authorization_code_pkce | authorization_code | device_code | import_token
  • Required hooks: buildAuthUrl(), exchangeToken(), mapTokens()
  • Optional hooks: postExchange() for provider-specific post-auth logic

Consequences

Positive

  • Adding new providers requires only a config entry + optional subclass
  • PKCE, state validation, and token exchange are shared (DRY)
  • Device code flow providers share polling logic

Negative

  • Some providers have unique quirks (Kiro uses AWS SSO OIDC with client registration)
  • Testing requires mocking external OAuth endpoints

Neutral

  • ~1050 lines in providers.js — could be further split per provider if needed