RLS policies implementation#95
Open
Swayymalcolm99 wants to merge 1 commit into
Open
Conversation
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.
Closes #32
Added Row Level Security (RLS) policies to prevent unauthorized data access
File Changed
20260718000000_rls_policies.sql (new)
What Was Implemented
Created RLS policies for 6 tables to ensure users can only access their own data:
learner_profiles - Users can read/insert/update their own profile
loans - Users can read their own loans; service role can insert/update (for indexer)
vouches - Users can read where they're mentor or learner; mentors can insert/update
vendors - Public read access (authenticated users); service role full access
liquidity_positions (pool_positions) - Users can read their own; service role insert/update
sponsor_pools - Users can read/insert/update their own sponsor pool
Key Design Decisions
Uses Postgres session variable app.current_wallet for wallet-based authentication
Service role bypasses RLS automatically for admin/indexer operations
repayment_installments table doesn't exist - payment_index is used instead (service role managed)
pool_positions is implemented as liquidity_positions
Testing
All CI checks pass: npm install , npm run build , npm test (288/288 tests)
Acceptance Criteria Met
All tables have RLS enabled (from previous migration)
Users can only access their own data
Public data (vendors) accessible without auth
Admin operations use service role
npm run build passes