How Camel Sets the UID
For every query executed through Camel, the system automatically sets a session variable:Setting Up RLS
Step 1: Enable RLS on Your Table
First, enable row-level security on the tables you want to protect:Once RLS is enabled, the table will deny all access by default unless you create policies to grant access.
Step 2: Create an RLS Policy
Create a policy that uses thecamel.uid
session variable to filter rows:
user_id
column matches their uid.
Complete Example: User Orders
Let’s implement RLS for an e-commerce scenario where users should only see their own orders.1. Create the Orders Table
2. Enable RLS
3. Create the Policy
4. Grant Permissions
Testing Your Policies
You can test your RLS policies directly in PostgreSQL:Troubleshooting
Users See No Data
- Verify the
camel.uid
is being set correctly - Check that your policy logic is correct
- Ensure the user has the necessary table permissions
Performance Issues
- Check if filter columns are indexed
- Analyze query plans for inefficient policy checks