PulseAugur
实时 23:36:04
English(EN) RLS recursion infinite loop: why I gave up policies and bet everything on a JWT custom claims hook

PostgreSQL RLS 策略导致无限递归循环

一位开发者在使用 Supabase 时,在 PostgreSQL 的行级安全 (RLS) 策略中遇到了无限递归错误。问题源于 `public.cours` 表上的一个策略查询了 `public.user_roles` 表,而 `public.user_roles` 表本身也有查询 `public.user_roles` 的策略。当向 `authenticated` 成员资格添加新的 `agent_readonly` 角色时,这会创建一个循环,导致 PostgreSQL 评估所有允许的策略。在最终决定将角色信息移出数据库并放入 JWT 自定义声明之前,开发者探索了诸如 `SECURITY DEFINER` 函数和角色隔离之类的解决方案。 AI

影响 N/A

排序理由 开发者描述了与数据库安全策略相关的技术问题和解决方案。

在 dev.to — Claude Code tag 阅读 →

AI 生成摘要 · Google Gemini · 来自 1 个来源。 我们如何撰写摘要 →

PostgreSQL RLS 策略导致无限递归循环

报道来源 [1]

  1. dev.to — Claude Code tag TIER_1 English(EN) · Michel Faure ·

    RLS recursion infinite loop: why I gave up policies and bet everything on a JWT custom claims hook

    <blockquote> <p>Episode <strong>1/4</strong> — 3 incidents, one root: default GRANTs open more than you think — [CANONICAL URL EPISODE 1: fill in after push]<br /> Episode <strong>2/4</strong> — <code>await mutation()</code> lies when nobody opens the <code>{ error }</code> envel…