Supabase Restrict Public Read Access to Table but Access It From Postgress Function

Lonare
3 min readMay 16, 2024

Securing Your Data: Restricting Public Access to PostgreSQL Tables with Functions

In the realm of database management, security is paramount.

Often, there’s a need to restrict access to certain tables or data while still allowing authorised users to interact with it through specific functions.

This is where PostgreSQL, a powerful open-source relational database, shines. In this article, we’ll explore how you can tighten the security of your PostgreSQL tables by restricting public access while enabling access through functions.

Understanding the Challenge

Imagine you have sensitive data stored in a PostgreSQL database table.

You want to prevent unauthorized users from directly querying or modifying this data, but you still need certain operations to be performed on it.

Here’s where the dilemma arises: how do you strike a balance between security and functionality?

Enter PostgreSQL Functions

PostgreSQL functions come to the rescue.

These are blocks of code that can accept parameters, perform complex operations, and return values.

--

--

Lonare

Imagination is the key to unlock the world. I am trying to unlock mine.