Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3fae667
fixed database migration
ngoiyaeric Dec 15, 2025
b02198c
fix(db): add drizzle db export and use supabase createMessage in cale…
ngoiyaeric Dec 15, 2025
a6c6e50
chore(rebase): resolve conflicts and apply calendar/db fixes
google-labs-jules[bot] Oct 12, 2025
b5b2209
Fix linting errors, server actions config, and chat history functiona…
Dec 16, 2025
2a49291
fix(chat): Fix chat saving functionality by using direct inserts and …
ngoiyaeric Dec 17, 2025
22a330a
Move history button to left, disable auth for testing, fix chat persi…
Dec 18, 2025
6f305ea
Add missing path and share_path columns to chats table
Dec 19, 2025
c8a1447
Fix chat creation and add debug logging
Dec 21, 2025
8aaf0d0
chore: resolve merge conflicts and change history toggle icon to plant
ngoiyaeric Dec 30, 2025
6c325e9
chore: synchronize with main branch
ngoiyaeric Dec 30, 2025
76d4da4
Merge branch 'main' into refactor/collaboration-ui-integration
ngoiyaeric Dec 31, 2025
9108ced
fix: enable mock auth to bypass Supabase requirement
ngoiyaeric Jan 1, 2026
f09b65b
feat: integrate auth frontend with supabase and connect to backend
ngoiyaeric Jan 5, 2026
88bb95e
fix: prevent static pre-rendering of auth page to fix build error
ngoiyaeric Jan 5, 2026
f6d9246
temp: make changes for auth redirect and logging
ngoiyaeric Jan 5, 2026
7ad992b
auth: enforce Supabase auth, fix auth page compilation and proxy head…
ngoiyaeric Jan 5, 2026
acaa818
fix: resolve critical auth backend schema security issues
CJWTRUST Jan 6, 2026
f018d85
Fix race condition in chat and add error handling to server actions
ngoiyaeric Jan 6, 2026
f0765e6
fix: correct Supabase schema discrepancies and security issues
CJWTRUST Jan 7, 2026
db59402
fix: set proper path for new chat creation
CJWTRUST Jan 7, 2026
c79b56c
fix: guard retrieveContext against empty/undefined userInput
CJWTRUST Jan 7, 2026
caac000
Merge origin/main and resolve conflicts
ngoiyaeric Jan 12, 2026
8b53b6e
Changes before Firebase Studio auto-run
ngoiyaeric Jan 13, 2026
3ebae0c
Merge origin/main into refactor/collaboration-ui-integration
ngoiyaeric Jan 13, 2026
7c96403
fix: update Message type to match AIMessage and fix content parsing i…
ngoiyaeric Jan 13, 2026
6604b7d
Merge branch 'main' into refactor/collaboration-ui-integration
ngoiyaeric Jan 14, 2026
c8441fd
fix: syntax error in app/actions.tsx and refactor getUIStateFromAIState
ngoiyaeric Jan 14, 2026
91488bb
Implement standard tier: 1/mo, 8000 credits, billed yearly
CJWTRUST Jan 14, 2026
c284e37
Changes before Firebase Studio auto-run
ngoiyaeric Jan 14, 2026
a40cd86
feat: Implement Standard Tier credit system
ngoiyaeric Jan 14, 2026
1f9de85
fix: update import in app/api/user/credits/route.ts
ngoiyaeric Jan 14, 2026
696c177
fix: add schema to drizzle instance in lib/db/index.ts
ngoiyaeric Jan 14, 2026
f30205b
fix: use getTierConfig in app/api/user/credits/route.ts
ngoiyaeric Jan 14, 2026
584015e
fix(auth,credits): enhance oauth error logging and integrate credits …
google-labs-jules[bot] Jan 17, 2026
7b9aeb2
chore: fix build and lint configuration
google-labs-jules[bot] Jan 19, 2026
8033da7
Merge pull request #439 from QueueLab/fix-build-and-lint-config-20008…
ngoiyaeric Jan 19, 2026
73bf12b
Merge branch 'main' into fix-oauth-and-credits-integration-2704938752…
ngoiyaeric Jan 19, 2026
caeb97a
Integrate billing popup, usage sidebar, and credit preview toggle int…
CJWTRUST Jan 20, 2026
19eb620
Fix regressions, security vulnerabilities, and architectural inconsis…
google-labs-jules[bot] Jan 20, 2026
349b637
Fix regressions, security, architectural inconsistencies, and refine UI
google-labs-jules[bot] Jan 20, 2026
be439d0
Fix regressions, security, architecture, and UI layout refinements
google-labs-jules[bot] Jan 20, 2026
ce41245
Address PR feedback and finalize UI layout refinements
google-labs-jules[bot] Jan 20, 2026
384a31e
Final UI refinements, PR feedback address, and auth fixes
google-labs-jules[bot] Jan 20, 2026
003cbb3
Final fix for UI, Auth, and Security issues
google-labs-jules[bot] Jan 20, 2026
0bcef46
Final resolution for all regressions, security, architecture, and UI …
google-labs-jules[bot] Jan 20, 2026
6cbf8cc
fix: RLS, persistence, and UI (credits + usage sidebar)
ngoiyaeric Jan 21, 2026
fd4526e
fix: authentication, chat history toggle, and UI improvements
CJWTRUST Jan 21, 2026
fe8dc87
Merge pull request #443 from QueueLab/pr-442
ngoiyaeric Jan 21, 2026
aececdf
Address PR feedback: simplify header triggers and verify mobile usage UI
google-labs-jules[bot] Jan 21, 2026
6af0fe0
feat: implement billing UI, authentication flow, chat retrieval, and …
CJWTRUST Jan 22, 2026
160f452
Add files via upload
ngoiyaeric Jan 22, 2026
87a2bb6
Fix regressions in security architecture: update auth, add user upgra…
ngoiyaeric Jan 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
AUTH_DISABLED_FOR_DEV=false
DATABASE_URL="postgresql://user:password@host:port/db"
SERVER_ACTIONS_ALLOWED_ORIGINS=*
STANDARD_TIER_BILLING_CYCLE="yearly"
STANDARD_TIER_CREDITS=8000
STANDARD_TIER_MONTHLY_PRICE=41
STANDARD_TIER_PRICE_ID="price_standard_41_yearly"
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key-here
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
STANDARD_TIER_BILLING_CYCLE="yearly"
STANDARD_TIER_CREDITS=8000
STANDARD_TIER_MONTHLY_PRICE=41
STANDARD_TIER_PRICE_ID="price_placeholder"
81 changes: 33 additions & 48 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,59 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build
# Dependency directories
node_modules/
.bun/

# Build outputs
.next/
dist/
build/
out/

# Environment variables
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
.env.*.local

# misc
# IDE/Editor
.vscode/
.idea/
*.swp
*.swo
.DS_Store
*.pem

# debug
# Logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local
# Lock files
bun.lockb

# log files
dev_server.log
server.log
# Testing
playwright-report/
test-results/
coverage/

# vercel
.vercel
# Supabase local CLI state
supabase/.temp/

# typescript
# Misc
.vercel/
*.tsbuildinfo
next-env.d.ts

# Playwright
/playwright-report/
/test-results/
/dev.log
# AlphaEarth Embeddings - Sensitive Files
# Add these lines to your main .gitignore

# GCP Service Account Credentials (NEVER commit)
gcp_credentials.json
**/gcp_credentials.json

# AlphaEarth Index File (large, should be downloaded separately)
aef_index.csv

# Environment variables with GCP credentials
.env.local
.env.production.local
*.log
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
74 changes: 74 additions & 0 deletions FIXES_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Auth Backend Schema Fixes - PR #327

## Summary of Changes

This commit addresses critical security vulnerabilities and auth backend schema issues identified in the CodeRabbit review.

## Critical Security Fixes

### 1. ✅ Deleted RLS Disable Migration
**File:** `supabase/migrations/0002_disable_rls_for_testing.sql` (DELETED)
- **Issue:** This migration disabled Row Level Security on all tables, creating a critical security vulnerability
- **Risk:** Anyone could read, modify, or delete ANY user's chats, messages, and participants
- **Fix:** Completely removed this migration file to ensure RLS remains enabled in production

### 2. ✅ Added pgcrypto Extension
**File:** `supabase/migrations/0000_init.sql`
- **Issue:** Used `gen_random_uuid()` without enabling the pgcrypto extension
- **Risk:** Migration would fail on typical Supabase setups
- **Fix:** Added `CREATE EXTENSION IF NOT EXISTS "pgcrypto";` at the start of the migration

### 3. ✅ Fixed User Lookup in Collaboration
**File:** `lib/actions/collaboration.ts`
- **Issue:** Queried non-existent `public.users` table instead of `auth.users`
- **Risk:** User invitation flow always failed
- **Fix:** Updated `inviteUserToChat()` to use `auth.admin.listUsers()` via the service client to properly look up users by email

### 4. ✅ Added Auth Check to RAG Function
**File:** `lib/actions/rag.ts`
- **Issue:** `retrieveContext()` had no authentication check
- **Risk:** Unauthorized users could access message embeddings
- **Fix:** Added authentication validation at the start of the function using `getCurrentUserIdOnServer()`

### 5. ✅ Added Environment Validation
**File:** `lib/supabase/client.ts`
- **Issue:** Service client creation didn't validate required environment variables
- **Risk:** Service client could fail silently, bypassing RLS checks
- **Fix:** Added proper validation with descriptive error messages for missing `NEXT_PUBLIC_SUPABASE_URL` or `SUPABASE_SERVICE_ROLE_KEY`

### 6. ✅ Improved INSERT Policy Security
**File:** `supabase/migrations/0002_add_insert_policy_for_chats.sql`
- **Issue:** Policy allowed any authenticated user to insert chats with any user_id
- **Risk:** Users could create chats impersonating other users
- **Fix:** Updated policy to enforce `auth.uid() = user_id`, ensuring users can only create chats where they are the owner

## Files Modified

1. `lib/actions/collaboration.ts` - Fixed user lookup to use auth.admin API
2. `lib/actions/rag.ts` - Added authentication check
3. `lib/supabase/client.ts` - Added environment variable validation
4. `supabase/migrations/0000_init.sql` - Added pgcrypto extension
5. `supabase/migrations/0002_add_insert_policy_for_chats.sql` - Improved security policy
6. `supabase/migrations/0002_disable_rls_for_testing.sql` - DELETED (critical security issue)

## Security Improvements

- ✅ RLS remains enabled on all tables
- ✅ All server actions now validate authentication
- ✅ User lookup uses proper Supabase auth APIs
- ✅ Environment variables are validated before use
- ✅ INSERT policies enforce proper ownership
- ✅ Database migrations will run successfully on standard Supabase setups

## Testing Recommendations

1. Verify RLS policies are active: Check Supabase dashboard
2. Test user invitation flow: Ensure users can be invited by email
3. Test RAG context retrieval: Verify auth check prevents unauthorized access
4. Test chat creation: Ensure users can only create chats as themselves
5. Run migrations on a test Supabase project to verify they execute without errors

## Related Issues

Addresses CodeRabbit review comments:
- [CodeRabbit Review Comment](https://github.com/QueueLab/QCX/pull/327#issuecomment-3714336689)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@



[**Pricing**](https://buy.stripe.com/14A3cv7K72TR3go14Nasg02)  |  [**Land**](https://wwww.queue.cx)  |  [**X**](https://x.com/tryqcx)
[**Pricing**]  |  [**Land**](https://wwww.queue.cx)  |  [**X**](https://x.com/tryqcx)

<a href="https://www.producthunt.com/products/qcx?embed=true&utm_source=badge-featured&utm_medium=badge&utm_source=badge-qcx" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1035588&theme=light&t=1762583679476" alt="QCX - Artificial&#0032;General&#0032;Intelligence&#0046; | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
</div>
Expand Down
Loading