---
title: "Flutter Authorization with RLS"
description: "Extends a basic Flutter real-time chat app into a 1-on-1 chat with authorization enforced by PostgreSQL Row Level Security on Supabase."
url: "https://swe.quest/articles/flutter-authorization-with-rls-f1170d28eed05738"
canonical: "https://supabase.com/blog/flutter-authorization-with-rls"
source: "Supabase"
published: "2022-11-22"
difficulty: "medium"
kind: "How-to"
reading_minutes: 25
tags: ["postgres","identity-auth","mobile","realtime"]
---

# Flutter Authorization with RLS

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2022-11-22, 25 min read, How-to. Original: [https://supabase.com/blog/flutter-authorization-with-rls](https://supabase.com/blog/flutter-authorization-with-rls)

## Summary

Extends a basic Flutter real-time chat app into a 1-on-1 chat with authorization enforced by PostgreSQL Row Level Security on Supabase. The schema adds rooms and room\_participants tables, a room\_id foreign key on messages, and a security-definer plpgsql function create\_new\_room that returns an existing room for two users or creates one. The client side uses flutter\_bloc cubits to stream room participants and each room's latest message via Supabase realtime. Email confirmation is handled through deep links configured in iOS Info.plist, AndroidManifest.xml and the Supabase redirect URL settings.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Real-time systems](https://swe.quest/tags/realtime.md) (Backend & APIs)

## Prerequisites

- Flutter basics
- SQL and PostgreSQL ([easy posts on SQL](https://swe.quest/tags/sql.md?difficulty=easy))
- Supabase client usage

## Keywords

Supabase, Flutter, Row Level Security, flutter\_bloc, PostgreSQL, supabase\_flutter

## Related posts

- [Flutter Tutorial: building a Flutter chat app](https://swe.quest/articles/flutter-tutorial-building-a-flutter-chat-app-942d133b45bb7fa6.md): Supabase · 2022-06-30 · Medium · 19 min read · Mobile, Real-time systems, PostgreSQL, Communications
  A real-time single-room chat app can be built with Flutter on the frontend and Supabase as the entire backend, using the supabase\_flutter SDK instead of a custom API.
- [Supabase Realtime: Broadcast and Presence Authorization](https://swe.quest/articles/supabase-realtime-broadcast-and-presence-authorization-db4d8e985aa735a7.md): Supabase · 2024-08-13 · Medium · 6 min read · Real-time systems, Identity & auth, PostgreSQL
  Supabase Realtime now supports authorization for Broadcast and Presence channels using Postgres Row Level Security policies on a managed \`realtime.messages\` table, where SELECT policies govern receiving and INSERT policies govern sending.
- [Authentication in Ionic Angular with Supabase](https://swe.quest/articles/authentication-in-ionic-angular-with-supabase-d02eec9140b86035.md): Supabase · 2022-11-08 · Medium · 33 min read · Identity & auth, Frontend, Mobile, PostgreSQL, TypeScript
  An Ionic Angular realtime messaging app built on Supabase demonstrates email/password signup and login, magic link authentication for web and native mobile, and route protection with Angular guards.
- [How to Set Up Row-Level Security in Postgres Using AWS Cognito](https://swe.quest/articles/how-to-set-up-row-level-security-in-postgres-using-aws-cognito-7cb6bed6c9694d22.md): Neon · 2024-12-04 · Medium · 5 min read · PostgreSQL, Identity & auth, JavaScript, Serverless
  Postgres row-level security can be driven by AWS Cognito JWTs: a Cognito User Pool issues tokens, and Neon Authorize validates them and maps claims like \`sub\` into Postgres session variables.
- [Modelling Authorization for a Social Network with Postgres RLS and Drizzle ORM](https://swe.quest/articles/modelling-authorization-for-a-social-network-with-postgres-rls-and-drizzle-orm-6267eb437b8171e7.md): Neon · 2024-11-11 · Medium · 8 min read · PostgreSQL, Identity & auth, TypeScript, System design
  Postgres Row-Level Security can express the full authorization model for a Twitter-like social network, defined with Drizzle ORM's crudPolicy and pgPolicy helpers and the pg\_session\_jwt extension's auth.user\_id().

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
