tftsr-devops_investigation/src-tauri/Cargo.toml
Shaun Arman 05f4b51370
Some checks are pending
Auto Tag / auto-tag (push) Waiting to run
Test / rust-fmt-check (push) Waiting to run
Test / rust-clippy (push) Waiting to run
Test / rust-tests (push) Waiting to run
Test / frontend-typecheck (push) Waiting to run
Test / frontend-tests (push) Waiting to run
feat: implement OAuth2 callback server with automatic token exchange
Phase 2.2: OAuth2 flow - Part 3 (Callback server) COMPLETE 

Implemented:
- Local HTTP server on localhost:8765 using warp
  * GET /callback?code=...&state=... - OAuth redirect handler
  * GET /health - Health check endpoint
  * Graceful shutdown with oneshot channel

- Automatic callback handling
  * Server auto-starts on first initiate_oauth call
  * Background task listens for OAuth redirects
  * Automatically exchanges code for token
  * Stores encrypted token in database
  * Logs audit event for each successful OAuth

- Updated initiate_oauth command
  * Starts callback server if not running
  * Stores (service, verifier) tuple in OAuth state
  * Returns auth URL to open in browser/webview

- Updated handle_oauth_callback_internal
  * Accepts AppState reference (not State)
  * Called automatically by callback server
  * Exchanges code, encrypts token, stores in DB

- Beautiful success/error HTML pages
  * Green checkmark on success
  * Auto-closes window after 3 seconds
  * Clear error messages on failure

- Global state management
  * OAUTH_STATE: Maps state key -> (service, verifier)
  * CALLBACK_SERVER_SHUTDOWN: Holds shutdown channel
  * Thread-safe with Mutex wrappers

Dependencies added:
- warp 0.3 - Lightweight HTTP framework

TDD tests (7 passing with --test-threads=1):
Callback server tests:
  * Health endpoint verification
  * Callback parameter parsing
  * Missing/partial parameter handling
  * Graceful shutdown

Integration command tests:
  * OAuth state storage and retrieval
  * Multiple key management
  * OAuthInitResponse serialization

COMPLETE OAUTH2 FLOW:
1. User calls initiate_oauth("confluence")
2. Callback server starts (if not running)
3. Frontend receives auth URL
4. User opens URL in browser/webview
5. User authorizes, redirected to localhost:8765/callback?code=...
6. Callback server receives redirect
7. Token exchanged automatically
8. Token encrypted and stored in DB
9. Success page shown to user
10. Window auto-closes

Next: Frontend components (AuthWindow, Settings UI, CSP updates)
2026-04-03 14:59:39 -05:00

53 lines
1.2 KiB
TOML

[package]
name = "tftsr"
version = "0.1.0"
edition = "2021"
[lib]
name = "tftsr_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-stronghold = "2"
tauri-plugin-dialog = "2"
tauri-plugin-fs = "2"
tauri-plugin-shell = "2"
tauri-plugin-http = "2"
rusqlite = { version = "0.31", features = ["bundled-sqlcipher-vendored-openssl"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.12", features = ["json", "stream"] }
regex = "1"
aho-corasick = "1"
uuid = { version = "1", features = ["v7"] }
printpdf = "0.7"
docx-rs = "0.4"
sha2 = { version = "0.10", features = ["std"] }
hex = "0.4"
anyhow = "1"
thiserror = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
chrono = { version = "0.4", features = ["serde"] }
futures = "0.3"
async-trait = "0.1"
base64 = "0.22"
dirs = "5"
aes-gcm = "0.10"
rand = "0.8"
lazy_static = "1.4"
warp = "0.3"
[dev-dependencies]
tokio-test = "0.4"
mockito = "1.2"
[profile.release]
opt-level = "s"
strip = true