1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

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

1
Posted at

Supabaseで

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

を調べるSQLです。

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

カラムレベルの権限はinformation_schemaのcolumn_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ではanonやauthenticatedになります。
  • table_nameはどのテーブルかを指します。
  • column_nameはどのカラムかを指します。
  • privilege_typeはそのカラムに対してSELECTやINSERT、UPDATEができるかを指します。

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

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?