auth-data-path-consistency

auth-data-path-consistency is a cursor rule for Cursor from YuDefine/nuxt-supabase-starter. It costs 0 tokens per session (2,261 once invoked), scanned A, original, MIT.

A rule for keeping an application's login system consistent with the way it accesses Supabase data. Supabase is a service that provides databases, authentication, and APIs; RLS means database rules that limit which rows a user can access.

In plain words
What is it for?
Use it when changing authentication, adding client-side Supabase queries, creating tables, or writing migrations with RLS policies and permissions.
Why use it?
It prevents a mismatch where the app shows a user as logged in but database requests use an anonymous identity, causing denied access or weaker permissions. It also requires checking database privileges alongside RLS policies.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/yudefine/nuxt-supabase-starter/auth-data-path-consistency
Clone the repo
git clone --depth 1 https://github.com/YuDefine/nuxt-supabase-starter

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for auth-data-path-consistency

README.md
[![agentmods](https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/auth-data-path-consistency.svg)](https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/auth-data-path-consistency)
Your own site
<a href="https://agentmods.dev/rules/yudefine/nuxt-supabase-starter/auth-data-path-consistency"><img src="https://agentmods.dev/badge/rules/yudefine/nuxt-supabase-starter/auth-data-path-consistency.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,261 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.02261
Opus 5 $0.00000 $0.01130
Sonnet 5 $0.00000 $0.00452
Haiku 4.5 $0.00000 $0.00226

Measured yesterday against content hash 97df15057ce2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

auth-data-path-consistency scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

template/.cursor/rules/auth-data-path-consistency.mdc · 94 lines

How it starts

The opening of the file, as written. The whole thing — 94 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Auth–Data Path 一致性

核心命題

瀏覽器的 Supabase client(useSupabaseClient())向 PostgREST 發 request 時,身分來自 Supabase Auth 的 JWT,不來自應用程式自己的 Cookie Session。若應用程式已移除或未使用 Supabase Auth(改用 nuxt-auth-utils、Better Auth 等),瀏覽器的 Supabase client 永遠以 anon role 存取,無論使用者是否已登入。

此規則防止「session 層已換、但 client 端仍直連 PostgREST」的混合狀態—— 2026-07-14 production 401 事故的根因。

Trigger

  • 更換或移除 auth 策略(Supabase Auth → nuxt-auth-utils / Better Auth,或反向)
  • 新增 client-side useSupabaseClient().from('table') 直連查詢
  • 新增 migration 含 RLS policy(CREATE POLICY ... TO authenticated
  • 新增 table 並決定 client 端存取方式

MUST

  1. 換 auth 策略時全面 audit call sites——列舉全部 useSupabaseClient()app/ 的使用點,逐一歸類:
    • 改走 server API($fetch / useFetch
    • 確認為純 Storage(supabase.storage.from())——Storage 有獨立 bucket policy,不受此規則約束
    • 確認仍有 Supabase Auth JWT 支撐(identity 來源未變)
  2. Migration 建 RLS policy 時同時驗證 GRANT——PostgreSQL 先查 table-level privilege 再評估 RLS policy。只建 TO authenticated policy 但沒有 GRANT SELECT ON <table> TO authenticated,結果是 42501(permission denied),RLS policy 完全不被評估。Migration 內 MUST 顯式 GRANT 或註明 table 已有既存 GRANT。
  3. 新增繞過 server 的資料路徑時標註 evlog 盲區——client-side PostgREST 直連不經 Nitro,evlog middleware 看不到。新增此類路徑 MUST 在 PR description 標註「此路徑在 evlog 觀測範圍外」。

NEVER

  1. NEVERGRANT ... TO anon 修 401——等於把資料公開給任何持有 publishable key 的人。401 的正解是修身分鏈,不是放寬權限。
  2. NEVER 留「session 層用 Cookie,但 DB policy 假設 Supabase JWT 存在」的混合狀態——瀏覽器不會因為帶著 Cookie Session 就自動變成 authenticated role。
  3. NEVER 為了取得 authenticated role 而自行簽 PostgREST JWT——同時維護 Cookie Session + JWT 兩套 session lifecycle(rotation、logout、角色同步)的複雜度通常比完整採用 Supabase Auth 更差。

Server 側:RLS policy 的前提條件

上面幾節管的是「瀏覽器直連 PostgREST」。本節管的是同一個身分鏈斷裂在 server 側的形態——它不會回 401,不會有任何錯誤,policy 靜靜地不放行或整個被繞過。

命題

RLS policy 裡的 auth.uid() 能取到值,前提是該 request 攜帶 Supabase Auth 簽發的 JWT。consumer 的 identity 來源若不是 Supabase Auth(Better Auth / nuxt-auth-utils / 自建 session),auth.uid() 靜默回 null——policy 語法正確、ENABLE ROW LEVEL SECURITY 也開著,但沒有任何 row 會通過。

Read the full file on GitHub · 94 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +3 lines 97df15057ce2
  2. 4d ago First seen · 91 lines · 0 tokens per session scan A e0c9bf05b0a6

Subscribe to this mod's changes

auth-data-path-consistency is a cursor rule published in the GitHub repository YuDefine/nuxt-supabase-starter (45 stars, last pushed yesterday), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,261 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.