Skip to content

feat(store,oauth): Phase 3A — User identity + OAuth token storage - #6

Merged
smallchungus merged 4 commits into
mainfrom
phase-3a-oauth-storage
Apr 18, 2026
Merged

feat(store,oauth): Phase 3A — User identity + OAuth token storage#6
smallchungus merged 4 commits into
mainfrom
phase-3a-oauth-storage

Conversation

@smallchungus

Copy link
Copy Markdown
Owner

Summary

Phase 3A: foundation slice for the Gmail/Drive integration that ships in 3B–3F.

  • Migration 0002_users_oauth_sync_processed: adds users, oauth_tokens, gmail_sync_state, processed_emails tables. ALTERs pipeline_jobs to add user_id, gmail_message_id, is_synthetic. Partial unique index on (user_id, gmail_message_id) for non-terminal non-synthetic rows.
  • internal/oauth: AES-GCM 256 Encrypt/Decrypt helpers. Validates key length (32 bytes). Random nonce per call. Tamper detection.
  • internal/store: CreateUser, GetUserByEmail (+ ErrUserNotFound), SaveOAuthToken (UPSERT), GetOAuthToken (+ ErrOAuthTokenNotFound). Tokens stored as opaque ciphertext — encryption happens above the store boundary.

10 new tests (4 oauth unit, 5 store integration, 1 migrate integration). Existing 23 still green.

Phase 3B (Gmail client + History sync) builds on top.

Test plan

  • make lint (0 issues)
  • make test-unit
  • make test-integration (17 store tests + 4 oauth unit + others — all green)
  • make k8s-validate
  • CI green

@smallchungus
smallchungus merged commit ba3abd3 into main Apr 18, 2026
3 checks passed
@smallchungus
smallchungus deleted the phase-3a-oauth-storage branch April 18, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant