---
title: "Multi-factor Authentication via Row Level Security Enforcement"
description: "Supabase Auth now offers TOTP-based multi-factor authentication to all users, built around separate enroll, challenge and verify endpoints."
url: "https://swe.quest/articles/multi-factor-authentication-via-row-level-security-enforcement-05f1f64f444784f0"
canonical: "https://supabase.com/blog/mfa-auth-via-rls"
source: "Supabase"
published: "2022-12-14"
difficulty: "medium"
kind: "Announcement"
reading_minutes: 5
tags: ["identity-auth","postgres"]
---

# Multi-factor Authentication via Row Level Security Enforcement

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2022-12-14, 5 min read, Announcement. Original: [https://supabase.com/blog/mfa-auth-via-rls](https://supabase.com/blog/mfa-auth-via-rls)

## Summary

Supabase Auth now offers TOTP-based multi-factor authentication to all users, built around separate enroll, challenge and verify endpoints. The challenge step is kept apart from verification so the flow can later support devices like Yubikeys. Issued JWTs carry an Authenticator Assurance Level claim (aal1 or aal2) and an Authenticator Method Reference claim listing the methods used, so Postgres Row Level Security policies can enforce MFA for all users or only for users with a verified factor. Those policies must be declared restrictive, because Postgres ORs permissive policies together.

Written by swe.quest, not by the author.

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

## Topics

- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)

## Prerequisites

- JWT basics
- Postgres Row Level Security ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))

## Keywords

Supabase Auth, TOTP, Row Level Security, JWT, AAL, AMR, SAML, WebAuthn

## Related posts

- [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.
- [Supabase Auth: SSO, Mobile, and Server-side support](https://swe.quest/articles/supabase-auth-sso-mobile-and-server-side-support-6a2bc9b0f4a5ef26.md): Supabase · 2023-04-13 · Medium · 7 min read · Identity & auth, PostgreSQL, Multi-tenancy, Mobile
  Supabase Auth adds SAML 2.0 single sign-on, a PKCE authorization flow for server-side rendering and mobile apps, and native Sign in with Apple on iOS.
- [Introducing Neon RLS: Simplifying Row-Level Security For Postgres](https://swe.quest/articles/introducing-neon-rls-simplifying-row-level-security-for-postgres-4b66d76670bb402f.md): Neon · 2024-10-30 · Medium · 6 min read · PostgreSQL, Identity & auth, Multi-tenancy, TypeScript
  Neon RLS lets Postgres row-level security policies authenticate requests with JWTs from any auth provider that exposes a JWKS URL.
- [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.
- [Partial data dumps using Postgres Row Level Security](https://swe.quest/articles/partial-data-dumps-using-postgres-row-level-security-7b8cbab5206adee8.md): Supabase · 2022-06-28 · Medium · 4 min read · PostgreSQL, Privacy, Identity & auth, Testing
  Postgres Row Level Security can produce a seed.sql containing only safe, non-customer rows: create a restricted \`exporter\` role, attach RLS select policies that filter which rows it can see, then run \`pg\_dump --data-only --enable-row-security\` as that role.

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)
