Repository navigation
feat(phase-5): Meta Account Connection & Unified Login - #5
Merged
Merged
Conversation
… gating, and webhooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 5 Completion Report — Meta Account Connection
Branch:
feat/phase-5-meta-account-connection(targetingmainvia PR #5)Spec Reference:
implementation (1).md(Sections 2, 8, 10, 11, 13, 15, 16, 17) &docs/operations/meta-app-setup.mdCloud Budget Impact:
$0/month(META_CONNECTIONS_MODE=mockby default until a real Meta App & Business Portfolio are configured; Supabase Free + Render Free + Cloudflare Pages Free)1. Delivered Capabilities
1.1 Database Schema & Tenant Isolation (
database/migrations/versions/0007_phase5_meta_connections.py)0006_phase4_cloud_editing_and_approvals -> 0007_phase5_meta_connections) applied to live Supabase PostgreSQL 17.12:meta_connections: stores opaquetoken_secret_refwith DB-levelCHECK (token_secret_ref LIKE 'secret://%')so raw Meta tokens can never be persisted in ordinary database columns, plusconnection_type,meta_business_id,config_id,granted_scopes,instagram_account_ids,page_ids,ad_account_ids, computedcapabilities, andreconnect_required_at/reconnect_reason.meta_connected_assets: stores only selected & eligible Instagram Professional (business/creator), Facebook Page, and optional Ad Account assets (enforcesCHECK (instagram_account_type IN ('business', 'creator'))).meta_webhook_events: signature-verified, deduplicated inbound webhook log (uq_meta_webhook_events_ws_event_id).ENABLE+FORCE ROW LEVEL SECURITYand least-privilegemetuse_appCRUD grants on all 3 tables.1.2 Meta Integration Layer (
packages/meta_integrations/)secret_store.py): Server-sideSecretStoreprotocol +EncryptedSecretStoreissuing opaquesecret://meta/{workspace_id}/{uuid}refs and scrubbing raw tokens from API views and logs (strictly separate from Meta Muse keys).capabilities.py): Section 2.3 minimal permission matrix, Section 8.4compute_capabilities(...)requiring BOTH granted scope AND eligible connected asset, and backendrequire_meta_capability(...)enforcing403 META_PERMISSION_MISSINGwith reconnect guidance (Acceptance#6).client.py):$0deterministicMockMetaGraphClientcovering Creator Pro (#4), Agency Business portfolio with unselected-asset exclusion (#5), Personal IG blocking (#3), and missing-scope gating (#6), plusLiveMetaGraphClientgated onMETA_APP_ID+META_APP_SECRET.service.py): Exact redirect URI allowlist validation, HS256 CSRF-bound state tied to(workspace_id, actor_user_id), server-side code exchange, personal IG blocking with conversion steps and zero stored connection, webhookGETchallenge +POSTX-Hub-Signature-256HMAC-SHA256 verification, revocation handling (reconnect_required+ vault secret deletion), and clean disconnect.1.3 FastAPI Routes, Meta App Setup Docs & Connection UI
apps/api/routes/meta.py):GET /api/v1/workspaces/{workspace_id}/meta/permission-matrixGET /api/v1/workspaces/{workspace_id}/meta/connectionsPOST /api/v1/workspaces/{workspace_id}/meta/connections/unified-login/startGET/POST /api/v1/workspaces/{workspace_id}/meta/connections/unified-login/callbackPOST /api/v1/workspaces/{workspace_id}/meta/connections/{connection_id}/reconnectDELETE /api/v1/workspaces/{workspace_id}/meta/connections/{connection_id}GET /api/v1/workspaces/{workspace_id}/meta/connections/{connection_id}/assetsGET /api/v1/workspaces/{workspace_id}/meta/connections/{connection_id}/capabilitiesGET/POST /api/v1/workspaces/{workspace_id}/meta/webhooksdocs/operations/meta-app-setup.md): Documents Meta Business Portfolio ownership, Unified Login Config ID, Standard vs Advanced Access App Review checklist, and permission matrix.apps/web/src/app/(app)/connections/page.tsx): Static-export/connectionspage with Creator Pro & Agency Business onboarding paths, personal IG eligibility test, connected account capability chips, disconnect action, and visible permission matrix (never asks users for passwords or raw tokens).2. Verification Summary
ruff format --check .ruff check .mypy apps packages database workers testspytest tests/unit -q55 passed in 1.49s)alembic heads0007_phase5_meta_connections (head)alembic upgrade head0006 -> 0007cleanlyFORCE RLS& E2E testspytest tests/integration/test_phase5_meta_rls.py -v2 passed in 18.76s)pnpm --dir apps/web lint && pnpm --dir apps/web typecheckNEXT_PUBLIC_API_URL=https://metuse-ai-api-preview.onrender.com pnpm --dir apps/web build14/14static pages including/connections)grepacross Phase 5 files0leaks)#3,#4,#5,#6,#183. Deployment & Next Phase
apps/web/out(including/connections) tohttps://develop.metuse-ai-web.pages.dev/connections./meta/*endpoints once PR feat(phase-5): Meta Account Connection & Unified Login #5 is merged intomain.#14,#15).