LoginSignup
1
1

More than 1 year has passed since last update.

Supabase: カラムの権限を調べるSQL

Posted at

Supabaseで

  • どのテーブルのどのカラムに
  • 誰が
  • INSERTSELECT, UPDATEできるか

を調べるSQLです。

カラムレベルでの権限を調べるSQL

カラムレベルの権限はinformation_schemacolumn_privilegesビューを開くと簡単にわかります。Supabaseでは、publicスキーマでのanonロールとauthenticatedロールの権限がアプリケーションが気にすべき権限なので、その2つに絞って見ると分かりやすいです。

select grantee, table_name, column_name, privilege_type
from information_schema.column_privileges
where table_schema = 'public'
  and grantee in ('anon', 'authenticated')
order by grantee, table_name, privilege_type, column_name;

実行結果の例

CleanShot 2021-07-18 at 09.27.25@2x.png

  • granteeが権限付与されたロール名です。Supabaseではanonauthenticatedになります。
  • table_nameはどのテーブルかを指します。
  • column_nameはどのカラムかを指します。
  • privilege_typeはそのカラムに対してSELECTINSERTUPDATEができるかを指します。

ここの結果に出てこないということは、その権限が無いということです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1