Minimizing RLS complexity with custom claims
In this section, we’ll reduce the RLS complexity for our existing policies and future policies by using something called a custom claim. This sounds very special but it’s just values that we add to the user object that are easily accessible.
Note
What you’ll learn in this section is part of RLS optimization, which is more extensively discussed in Chapter 10 and Chapter 13. The difference is that, in this section, we are only optimizing for the sake of having less overall complexity and hence more safety while later, you’ll learn about further optimization tricks.
In Chapter 5, I told you that there is a column in the auth.users
table of Supabase that’s tailored for custom data that cannot be edited by the user on its own, but only by us, or more specifically by an admin Supabase client. It’s the raw_app_meta_data
column (though when dealing with it technically, such as through the Supabase...