Snowflake Postgres-Rollen

Postgres verfügt über eine eigene rollenbasierte Authentifizierung zum Verwalten von Verbindungen zu Datenbanken und zum Verwenden von Datenbanken auf einem Postgres-Server. Diese Rollen sind anders als die Rollen in Snowflake. Postgres-Rollen werden für den Zugriff auf und die Verwaltung von Datenbanken, Tabellen und anderen Objekten innerhalb von Snowflake Postgres-Instanzen verwendet.

Wenn Sie eine Instanz erstellen, erstellt Snowflake automatisch zwei spezielle verwaltete Rollen, die Sie nutzen können. Diese werden im Folgenden beschrieben.

Weitere Informationen zur Verwaltung von Postgres-Rollen finden Sie in der Postgres-Dokumentation.

Bemerkung

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.

Von Snowflake Postgres verwaltete Rollen

Snowflake Postgres automatically creates two managed roles at the same time that it creates your instance.

Rolle snowflake_admin

Die Rolle snowflake_admin ist eine Postgres-Rolle mit hohen Berechtigungen, mit der Ihre Snowflake-Postgres-Instanz verwaltet wird. Dies ist kein vollständiger Postgres-Superuser; einige Vorgänge bleiben eingeschränkt und werden von Snowflake verwaltet. Die Rolle verfügt jedoch über erhöhte Berechtigungen, die Folgendes umfassen:

  • Erstellen und Verwalten von Postgres-Rollen

  • Erstellen und Verwalten von Datenbanken

  • Verwalten der Replikation für Ihre Snowflake Postgres-Instanz

  • Umgehen der Sicherheit auf Zeilenebene (RLS), wo zutreffend.

Darüber hinaus ist snowflake_admin Mitglied mehrerer integrierter Postgres-Rollen, die Überwachungs- und Betriebsfunktionen gewähren, einschließlich:

  • pg_signal_backend

  • pg_use_reserved_connections

  • pg_create_subscription

  • pg_read_all_settings

  • pg_read_all_stats

  • pg_stat_scan_tables

  • pg_monitor

  • snowflake_admin_group

Rolle application

Die application-Rolle ist eine Nicht-Superuser-Rolle, die standardmäßig über die Berechtigungen verfügt, Objekte in der postgres-Datenbank zu erstellen. Neue Berechtigungen oder die Eigentümerschaft für diese Rolle sollten von der snowflake_admin-Rolle gewährt werden-

Sicherheit von Postgres-Kennwörtern

Neuerstellen von Anmeldeinformationen für von Snowflake Postgres verwaltete Rollen

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.

Über das Dashboard können Sie die Anmeldeinformationen für die snowflake_admin-Rolle Ihrer Instanz neu generieren.

  1. Wählen Sie im Navigationsmenü die Option Postgres aus.

  2. Wählen Sie Ihre -Instanz aus.

  3. Wählen Sie oben rechts im Menü Manage die Option Regenerate credentials aus.

  4. Klicken Sie auf die Schaltfläche Acknowledge & continue, um die Aktion zu bestätigen.

Festlegen von Kennwörtern für andere Postgres-Rollen

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.

Deaktivieren der Anweisungsprotokollierung für die CREATE ROLE- und ALTER ROLE-Befehle von 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;
Copy

Verwenden der psql des Postgres-Client-Befehls \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:
Copy

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
Copy

Rolleneinschränkungen

In Snowflake Postgres sind bestimmte Vorgänge für den Service selbst reserviert und können von keiner vom Kunden verwalteten Rolle ausgeführt werden, auch nicht von snowflake_admin. Diese Beispiele sind:

  • 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.

  • Der Zugriff auf die allgemeine Dateizugriffsfunktionen von Postgres, die den Zugriff auf das Dateisystem erlauben.

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.