Commit 49761f8
feat(core): Implement OAuth flows and DefaultTokenManager (#9)
Introduce comprehensive OAuth 2.0 support with Authorization Code + PKCE
and device code flows, along with a complete TokenManager implementation.
- Add `ProviderConfig` for OAuth provider metadata
- Add `ProviderRegistry` with pre-configured GitHub, Spotify, and Google providers
- Store provider endpoints, capabilities (PKCE, device code), and default scopes
- **PKCE Flow** (`oauth::pkce`): Authorization Code + PKCE for web/native apps
- Generate PKCE code verifier and challenge
- Build authorization URLs with CSRF state protection
- Exchange authorization codes for tokens
- Local callback listener for redirect handling
- **Device Code Flow** (`oauth::device_code`): For headless/limited-input devices
- Request device and user codes
- Poll token endpoint with proper error handling
- Support authorization_pending, slow_down, expired_token errors
- Implement `DefaultTokenManager<S: SecretStore>`
- Automatic token refresh when expired (5-minute buffer)
- Store/retrieve access tokens, refresh tokens, expiry, and scopes
- Client credentials management via SecretStore
- Rich error reporting (NotFound, Expired, RefreshFailed, etc.)
- Add `TokenScopes` credential type for persisting OAuth scopes
- Add `oauth2` v4.4 for OAuth protocol handling
- Add `reqwest` v0.12 for HTTP client operations
- Add `rand` v0.8 for secure random string generation
- Add `wiremock` v0.6 for integration testing
- Comprehensive integration tests for token refresh scenarios
- Mock OAuth endpoints with wiremock
- Test expiry detection, refresh success/failure, persistence
- Test multi-account support and scope handling
Closes #9
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <[email protected]>1 parent 1a6e8c2 commit 49761f8
File tree
10 files changed
+3075
-10
lines changed- sigilforge-core
- src
- oauth
- tests
10 files changed
+3075
-10
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| |||
67 | 76 | | |
68 | 77 | | |
69 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
168 | 171 | | |
169 | 172 | | |
170 | 173 | | |
| |||
179 | 182 | | |
180 | 183 | | |
181 | 184 | | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
| |||
0 commit comments