Snowflake Postgresのロール¶
Postgresには、データベースへの接続を管理し、Postgresサーバーでデータベースを使用するための独自のロールベース認証があります。これらのロールは、Snowflakeのロールとは別です。Postgresロールは、Snowflake Postgresインスタンス内のデータベース、テーブル、およびその他のオブジェクトにアクセスして管理するために使用されます。
インスタンスを作成すると、Snowflakeは自動的に2つの特別な管理ロールを作成します。それらのロールについて以下で説明しています。
Postgresロールの管理の詳細については、 Postgresドキュメント をご参照ください。
注釈
Here and in many other places you will see the terms "role" and "user" used interchangeably in the context of Postgres user management. This is because a Postgres user is simply a role that has the Postgres role LOGIN attribute.
Snowflake Postgres管理ロール¶
Snowflake Postgres automatically creates two managed roles at the same time that it creates your instance.
``snowflake_admin``ロール。¶
snowflake_admin ロール は、Snowflake Postgresインスタンスを管理するために使用される、高い権限を持つPostgresロールです。完全なPostgresスーパーユーザーでは ありません 。一部の操作は引き続き制限されており、Snowflakeによって管理されます。ただし、次のような昇格された権限を持ちます。
Postgresロールの作成と管理。
データベースの作成と管理。
Snowflake Postgresインスタンスの複製の管理。
行レベルセキュリティ( RLS )ポリシーのバイパス(該当する場合)。
さらに、 snowflake_admin は、次のような監視と操作機能を付与する複数のPostgres組み込みロールのメンバーです。
pg_signal_backendpg_use_reserved_connectionspg_create_subscriptionpg_read_all_settingspg_read_all_statspg_stat_scan_tablespg_monitorsnowflake_admin_group
``application``ロール。¶
application ロールは非スーパーユーザーロールであり、デフォルトで postgres データベースでオブジェクトを作成する権限を持っています。このロールの新しい権限または所有権は、 snowflake_admin ロールによって付与される必要があります。
Postgresのパスワードセキュリティ¶
Snowflake Postgres管理ロールの認証情報の再生成¶
Credentials for the snowflake_admin and application roles are generated when you create the instance and are displayed only once.
You can regenerate these credentials at any time, invalidating the existing credentials.
ダッシュボードから、インスタンスの snowflake_admin ロールの認証情報を再生成できます。
ナビゲーションメニューで Postgres を選択します。
インスタンスを選択します。
右上の Manage メニューで Regenerate credentials を選択します。
Acknowledge & continue ボタンをクリックして、アクションを確認します。
snowflake_adminまたはapplicationロールの認証情報を再生成するには、 RESET ACCESS パラメーターを指定して ALTER POSTGRES SERVICE コマンドを使用します。ALTER POSTGRES SERVICE [IF EXISTS] <name> RESET ACCESS FOR { 'snowflake_admin' | 'application' }
OWNERSHIP または OPERATE 権限が必要です。
That command returns one row with the following column:
password
認証情報のローテーションの例
my_instanceという名前のSnowflake Postgresインスタンスのsnowflake_adminロールのアクセスをリセットします。ALTER POSTGRES SERVICE my_instance RESET ACCESS FOR 'snowflake_admin';
他のPostgresロールのパスワードの設定¶
Snowflake Postgres instances are configured for scram-sha-256 password authentication. When new
passwords are set, a scram-sha-256 hash is generated and stored by the server, but when the Postgres
log_statement parameter
is set to any value other than none, then CREATE ROLE and ALTER ROLE DDL commands are fully
logged to the Postgres server log. Therefore, you should make sure that clear-text passwords are not
logged as part of those statements.
CREATE ROLE および ALTER ROLE Postgres DDL コマンドのステートメントログの無効化¶
The simplest way to prevent clear-text passwords used in CREATE ROLE and ALTER ROLE DDL statements from appearing in the Postgres server
log is to disable the log_statement parameter for the transaction that you run them in. Do so by using SET LOCAL:
BEGIN;
SET LOCAL log_statement = 'none';
CREATE USER mynewrole PASSWORD 'mynewpassword';
COMMIT;
psql Postgresクライアントの \password コマンドの使用¶
The Postgres psql client program has a
password <https://www.postgresql.org/docs/current/app-psql.html>_ meta-command that can be used
to change the password for existing users. The \password meta-command precomputes the entered
password's scram-sha-256 hash and uses that in the ALTER ROLE command that is sent to the server. To
use this method, first create new users without a password, and then set each user's password with
the psql \password meta-command.
postgres=# CREATE ROLE mynewrole LOGIN;
CREATE ROLE
postgres=# \password mynewrole
Enter new password for user "mynewrole":
Enter it again:
If log_statement is set to a value other than 'none', then the log entry for ALTER ROLE
command sent by psql for the above \password command has the calculated scram-sha-256
hash instead of the actual clear-text password. You can combine this method with disabling
log_statement completely, as described above, to prevent even that hash from appearing in the
Postgres log:
postgres=# CREATE ROLE mynewrole LOGIN;
CREATE ROLE
postgres=# BEGIN;
BEGIN
postgres=# SET LOCAL log_statement = 'none';
SET
postgres=# \password mynewrole
Enter new password for user "mynewrole":
Enter it again:
postgres=# COMMIT;
COMMIT
ロールの制限¶
Snowflake Postgresでは、特定の操作がサービス自体に予約されており、 snowflake_admin などの顧客管理ロールでは実行できません。例は次のとおりです。
Changing protected server-level configuration parameters that are managed by Snowflake.
Modifying or disabling core Snowflake-managed components or extensions.
Accessing or altering Snowflake-managed system databases or schemas used by the service.
Accessing or altering the Snowflake Postgres instance filesystem.
Direct modification of system catalog tables.
Creation of other superusers.
Creation of more than 64 roles in the instance.
Creation of more than 32 databases in the instance.
Execution of the ALTER SYSTEM command.
ファイルシステムのアクセスを許可するには、Postgresの 汎用ファイルアクセス関数 にアクセスします。
The Snowflake Postgres extension may introduce further restrictions on what both snowflake_admin
and application can do within an instance. These extension-specific limitations may evolve over
time and will be documented with the corresponding extension behavior. If an operation is blocked,
you receive an error indicating that it isn't permitted in Snowflake Postgres.