アプリ仕様の概要

This topic describes how a provider can configure a Snowflake Native App to use app specifications to request controlled access from consumers. App specifications allow consumers to review and approve or decline requests for the following actions:

  • Snowflakeの外部にある外部エンドポイントへの接続

  • サードパーティサービスによる認証

  • 他のSnowflakeアカウントとのデータ共有

Snowflake Native Apps のアクセス制御のタイプ

Snowflake Native Apps は、コンシューマーのSnowflakeアカウント以外のリソースとやり取りする必要があることがよくあります。これらの相互作用には、外部サービスへの接続、サードパーティプロバイダーとの認証、他のSnowflakeアカウントとのデータ共有などがあります。

To access external services and share data, Snowflake provides the following objects:

外部アクセス統合:

ユーザー定義関数またはストアドプロシージャ内で外部ネットワークエンドポイントへのセキュアアクセスを許可します。外部アクセス統合は、ネットワークルールを使用して、特定の外部ネットワークロケーションへのアクセスを制限する。

セキュリティの統合:

OAuth などのサードパーティの認証プロバイダーへの安全なアクセスを許可します。セキュリティ統合は、安全な認証とアクセス制御を提供します。

共有とリスト:

アプリがプロバイダーまたはサードパーティのSnowflakeアカウントにデータを共有するようにします。共有には共有されるデータベースオブジェクトが含まれ、リストはアカウントとリージョン間でデータを共有するメカニズムを提供します。

When using automated granting of privileges, an app has the required privileges to create these objects when running the setup script. However, because these objects enable external connections or data sharing, consumers must approve these operations when configuring the app.

アプリ仕様で権限の自動付与を使用すると、次のような利点があります。

  • Consumers do not have to manually create integrations, shares, or listings required by the app and approve access to them using references.

  • プロバイダーは、インストール中やアップグレード時に、必要な権限やオブジェクトの存在をチェックするコードを記述する必要がありません。

  • コンシューマーは、外部接続とデータ共有リクエストを明確に可視化し、制御できます。

Use app specifications for consumer approval

App specifications allow you to specify what controlled access the app requires. After the consumer installs the app, they review the app specification and approve or decline each request as necessary. This includes requests for external connections, authentication integrations, and data sharing permissions.

アプリ仕様定義

An app specification definition contains the properties that are required for the app to perform controlled operations such as external connections or data sharing. These properties are displayed to the consumer for approval. The app specification definition contains a subset of the metadata and properties specific to each type of operation: external access integration, security integration, or listing.

セキュリティ統合のアプリ仕様定義については、セキュリティ統合のアプリ仕様定義 をご参照ください。

外部アクセス統合のアプリ仕様定義については、App specification definition for an EAI をご参照ください。

For information about the app specification definition for listings, see リストのアプリ仕様の作成.

Sequence numbers of an app specification

シーケンス番号は、アプリ仕様のバージョン番号に似ています。シーケンス番号は、プロバイダーがアプリ仕様の定義を変更すると自動的に増加されます。アプリ仕様の定義には、構成の詳細やその他の必要な情報が含まれます。定義の一部ではないフィールド description などは、シーケンス番号の更新をトリガーしません。

シーケンス番号により、プロバイダーとコンシューマーはアプリ仕様のさまざまなバージョンを識別できます。たとえば、プロバイダーがアプリ仕様定義に新しい構成の詳細を追加すると、シーケンス番号が増えます。コンシューマーがアプリ仕様を表示すると、シーケンス番号が変わったことを確認でき、更新されたアプリ仕様を確認できます。

アプリ仕様を使用する場合のベストプラクティス

Automated granting of privileges ensures that the app has the required privileges to create objects like external access integrations, security integrations, or listings. However, consumers can choose to decline the app specification that enables external connections or data sharing. When developing an app, you must account for situations where app specifications might not be approved.

次のシナリオを検討してください。

  • An app might request multiple network ports for an external access integration, but the consumer might allow only one. The app should include logic to handle errors that occur if a network port is not available.

  • データ共有のリクエストは、一部のターゲットアカウントでは拒否または部分的にのみ承認される場合がありますが、他のアカウントでは承認されません。アプリはこうしたケースを適切に処理する必要があります。

  • 認証の統合は拒否される可能性があり、アプリに代替方法を使用する必要があります。

ベストプラクティスとして、常に適切なエラー処理を含め、どの機能が動作するために承認された仕様を必要とするかについて、明確なフィードバックをコンシューマーに提供します。

アプリ仕様でのコールバック関数の使用

In some contexts, an app might need to know when the consumer has approved or declined an app specification. For example:

  • アプリは、API 呼び出しを行う前に、外部アクセス仕様が承認されるまで待機する必要がある場合があります。

  • データ入力は、リスト仕様が承認された後にのみ開始する必要がある場合があります。

  • セキュリティ統合の承認後に、OAuth フローを初期化する必要がある場合があります。

この状況に対処するため、 Snowflake Native App Framework は、コンシューマーがアプリ仕様を承認または却下したときに実行されるコールバックストアドプロシージャをプロバイダーが定義できるメカニズムを提供します。

プロバイダーは、次の例に示すように、マニフェストファイルにストアドプロシージャを追加できます。

lifecycle_callbacks:
  specification_action: callbacks.on_spec_update
Copy

This example shows how to add a stored procedure named callbacks.on_spec_update to the manifest file. In the setup script, providers can add a stored procedure as shown in the following example:

CREATE OR REPLACE PROCEDURE callbacks.on_spec_update (
  name STRING,
  status STRING,
  payload STRING)
  ...
Copy

This example shows the signature of a stored procedure called callbacks.on_spec_update. You include the code in the body of this procedure to check the status of the app specification, create objects, and perform actions as required.