配置应用程序所需的权限¶
本主题介绍在安装或升级 Snowflake Native App 时如何使用自动授予权限向使用者请求权限。
自动授予权限概述¶
Often, an app needs to create objects or perform other actions in the consumer account. This requires the consumer to grant the required privileges that allow the app to perform these actions. For example, apps must have privileges to perform the following types of tasks:
创建并启动仓库和计算池。
访问消费者账户中的数据。
Connect to external endpoints outside of Snowflake.
通过使用自动授予权限,提供商可以在应用程序的清单文件中指定所需的权限。当使用者安装或升级应用程序时,清单中指定的权限将自动授予该应用程序。
小心
提供商必须传达这些权限及其潜在影响,以便使用者在评估和安装应用程序时可以查看这些权限及其潜在影响。在安装或升级期间自动授予权限后,这些权限便无法撤销。
Security considerations when using automated granting of privileges¶
当提供商将应用程序配置为在清单文件中使用 manifest_version: 2,启用了自动授予权限。默认情况下,这允许 Snowflake 自动向应用程序授予某些权限。有关可以自动向应用程序授予的权限的信息,请参阅 通过自动授予权限授予的权限。
在安装过程中,Snowsight 显示有关应用程序请求的权限的通知。当使用者安装使用自动授予权限的应用程序时,即表示他们同意在升级期间可以向应用程序授予这些权限,而无需额外同意。
使用者可以创建功能策略,限制应用程序可以创建的对象。有关创建功能策略的更多信息,请参阅 使用功能策略限制应用程序可以创建的对象。
使用自动授予权限为应用程序请求权限¶
Providers can use automated granting of privileges to specify the privileges an app needs to create and use objects in the consumer account. Automated granting of privileges grants the required privileges to the app when the consumer installs or upgrades the app.
设置清单文件的版本¶
要启用应用程序权限的自动授予,请在清单文件的开头设置版本,如以下示例所示:
manifest_version: 2
在清单文件中指定权限¶
要指定应用程序所需的权限,提供商必须在应用程序的清单文件中声明这些权限。
备注
要使用自动授予权限,提供商必须指定 manifest_version: 2。
以下示例显示如何在清单文件中指定 CREATE WAREHOUSE 权限:
manifest_version: 2
...
privileges:
- CREATE WAREHOUSE:
description: "Allows the app to create warehouses in the consumer account"
当使用者安装应用程序时,CREATE WAREHOUSE 权限会自动授予该应用程序。
小心
如果提供商将清单文件的 manifest_version 属性从 2 更改为 1,则在升级期间将撤销应用程序的所有自动权限。如果使用者已明确授予应用程序权限,则这些权限将保持不变。
备注
提供商只能在对应用程序的新版本进行重大升级期间更改 manifest_version 属性。在补丁发布中,manifest_version 无法更改。
在安装脚本中创建所需的对象¶
Using automated granting of privileges, providers can add the SQL commands to the setup script to create and access objects in the consumer account.
以下示例显示如何在使用者账户中创建仓库:
CREATE OR REPLACE WAREHOUSE application_wh;
此命令用于在使用者账户中创建一个名为 application_wh 的仓库。自动授予权限功能允许应用程序直接创建仓库。提供商不必添加额外的逻辑来检查使用者是否已授予所需的权限。
通过自动授予权限授予的权限¶
自动授予权限支持以下权限:
EXECUTE TASK
EXECUTE MANAGED TASK
CREATE WAREHOUSE
CREATE COMPUTE POOL
BIND SERVICE ENDPOINT
CREATE DATABASE
CREATE EXTERNAL ACCESS INTEGRATION
CREATE SECURITY INTEGRATION
CREATE SHARE
CREATE LISTING
当提供商将这些权限添加到清单文件时,它们将在安装和升级期间自动授予应用程序。
Restrictions on privileges gated by app specifications¶
The following privileges allow apps to create objects, but require additional app specification approval:
- CREATE EXTERNAL ACCESS INTEGRATION
Allows an app to create an external access integration in the consumer account. However, to allow connections to an external endpoint, consumers must also approve the app specification that allows the app to connect to external hosts.
- CREATE SECURITY INTEGRATION
Allows an app to create a security integration in the consumer account. However, to enable OAuth authentication, consumers must also approve the app specification that defines the OAuth endpoints and scopes.
- CREATE SHARE and CREATE LISTING
Allow an app to create shares and listings in the consumer account. However, to share data with target accounts, consumers must also approve the app specification that specifies the target accounts and auto-fulfillment settings.
For more information about app specifications, see Overview of app specifications.
未通过自动授予权限授予的权限¶
某些权限不会自动授予应用程序。使用者在安装或升级应用程序时必须手动授予这些权限。例如,以下权限不会自动授予应用程序:
MANAGE WAREHOUSES
IMPORTED PRIVILEGES ON SNOWFLAKE DB
READ SESSION
EXECUTE ALERT
在升级期间使用自动授予权限¶
发布应用程序的新版本时,您可能需要添加或移除该应用程序所需的权限。新版本或补丁的安装脚本同时使用了清单中指定的新自动权限和先前版本所需的权限运行。应用程序升级完成后,系统会撤销新版本中移除的所有多余权限。
为确保升级期间的稳定性,当清单文件的版本设置为 2 时,清单文件中请求的权限列表无法作为补丁的一部分进行修改。这可防止提供商在补丁中意外移除必要权限,从而导致应用程序无法正常运行。