feat(rls): implement Row Level Security policy management#17
feat(rls): implement Row Level Security policy management#17weroperking merged 1 commit intomainfrom
Conversation
- Add CLI commands for RLS policy management (create, list, disable) - Add core library modules for defining/scanning/generating SQL policies - Add RLS session middleware for authentication integration - Add migration integration for applying RLS policies to database - Fix SQL injection vulnerabilities with input validation - Add fallback parser for cross-runtime compatibility Security fixes: - Validate setting names in generateAuthFunctionWithSetting() - Validate policy names in policyExists() check - Remove unsafe type assertions in middleware
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR introduces comprehensive Row Level Security (RLS) support, adding CLI commands for policy management, context generation with AI integration, session middleware, database migration capabilities, and core RLS utilities including policy generation, scanning, and authentication functions across the framework. Changes
Sequence Diagram(s)sequenceDiagram
participant User as Developer (CLI)
participant CLI as RLS Command
participant Scanner as Policy Scanner
participant Generator as SQL Generator
participant DB as Database
participant Log as Logger
User->>CLI: runMigration(projectRoot, db, provider)
CLI->>Scanner: scanRLSPolicies(projectRoot)
Scanner->>Scanner: Find *.policy.ts files
Scanner->>Log: Log loaded policies
alt Policies Found
CLI->>Generator: policyToSQL(policies)
Generator->>Generator: Generate CREATE POLICY + auth.uid() SQL
Generator->>Log: Log generated statements
CLI->>DB: executeStatements(sqlStatements)
DB->>DB: Apply policies & auth function
DB-->>CLI: Success
CLI->>Log: Log RLS migration success
else No Policies
CLI->>Log: Skip RLS migration (info)
end
CLI-->>User: Migration complete
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR implements Row Level Security (RLS) support for the BetterBase framework.
Changes
Security Fixes
Summary by CodeRabbit