アプリケーションロール:コンシューマーが同じデータの各種ビューを共有できるようにする

プロバイダーは、アプリケーションロールを Declarative Native App に含めることで、コンシューマーエクスペリエンスを向上させることができます。アプリケーションロールは、Declarative Native App のコンテキスト内で作成された認証情報です。アプリケーションロールの情報については、アプリケーションロールについて をご参照ください。

アプリケーションロールはアプリケーションのセキュリティを分離するので、アプリケーションの特定のセキュリティ認証情報を、より広範なコンシューマーの組織のセキュリティモデル内で管理する必要がありません。 アプリケーションロールを使用すると、プロバイダーはアプリケーションリソースへのアクセスを簡単に制御できます。コンシューマーアカウントは、シンプルな SQL GRANT ステートメントを使用して、アプリケーションのロジックとデータへのアクセスを付与できます。

たとえば、アプリケーションが Operations アプリケーションロールを使用してログテーブルにアクセスする場合、コンシューマーはアプリケーションのコンテキスト外でそのアプリケーションロールを維持する必要はありません。知っておく必要があるのは、Operations アプリケーションロールを使用してサポートチームとアプリケーションを共有できるということだけです。

Using the manifest file, you define application roles, and assign them to content in the app. When the consumer installs the app, they can share the content with their organization members by assigning the application roles to their account roles and users. Consumers can also create hierarchies of application roles by assigning application roles to other application roles.

アプリケーションロールにより、コンシューマーは組織のメンバーとさまざまな方法でデータを共有できます。たとえば、1つのアプリに、データの完全なビューを含むノートブックと、フィルタリングされたビューを含むノートブックという、データを表示する2つのノートブックを含めることができます。

同じデータの2つのビューを含むアプリのコンポーネント。

これで、コンシューマーアプリの所有者は、フィルタリングされたビューをチームと共有することを選択できる一方、自分自身は完全なビューにアクセス可能なままです。

アプリの所有者が組織内のチームにアプリのロールを割り当てる

アプリケーションロールを使用してデータベースリソースへのアクセスを許可すると、子リソースは親リソースのロールを継承します。たとえば、アプリケーションロールをスキーマに割り当てると、そのスキーマのすべてのテーブルとビューがそのロールを継承します。データベースにアプリケーションロールを割り当てると、そのデータベースのすべてのスキーマ、テーブル、およびビューがロールを継承します。

マニフェストファイルのコンテンツにアプリケーションロールを割り当てる

  1. In the manifest file, in the top-level roles field, define the available application roles, for example, sales, marketing, and operations.

    roles:
      - sales:
          comment: "The sales role provides access to the filtered view of the sales data."
      - marketing:
          comment: "The marketing role provides access to the filtered view of the marketing data."
      - operations:
          comment: "The operations role provides access to the full view of the data, including logs."
    
    Copy
  2. リストを使用して、マニフェストファイルのコンテンツにアプリのロールを割り当てます。例: roles: [sales, support]

    - customer_table:
      roles: [sales,marketing] # Accessible to sales and marketing, app owners
    
    Copy
  3. テーブルを追加するには、ロールを <named table>.roles と、テーブルが存在する <named schema>.roles の両方に追加します。

    schemas:
      - sales_table:
        roles: [sales]
    tables:
      - sales_table:
        roles: [sales]
    
    Copy
  4. ビューを追加するには、ロールを <named view>.roles と、ビューが存在する <named schema>.roles の両方に追加します。

    schemas:
       - sales_view:
         roles: [sales]
    views:
       - sales_view:
         roles: [sales]
    
    Copy
  5. テーブルのフィルタリングされたビューを追加する場合は、基になるテーブルを追加しないでください。これにより、ユーザーがフィルター処理されていないデータにアクセスすることを防ぎます。

  6. ノートブックを含めるには、ロールを <named notebook>.roles に追加し、ノートブックで参照されるテーブルとビュー(およびその基になるスキーマ)を追加します。

    notebooks:
      - SALES_NB:
        main_file: ALL-DATA.ipynb
         roles: [sales]
         comment: Accessible to sales and app owners, references full view of the sales data
    
    Copy
  7. テーブルのフィルタリングされたビューを参照するノートブックを追加する場合は、基になるテーブルを追加しないでください。これにより、ユーザーによるフィルター処理されていないデータへのアクセスを防ぎます。

  8. To give an object no app roles, either leave the field empty ([]) or omit it. These objects are only accessible by the app owner and roles with granted IMPORTED PRIVILEGES.

- my_schema:
  roles: [] # Accessible to app owners only
Copy

マニフェストファイルの例:

roles:
  - sales:
      comment: "The sales role provides access to the filtered view of the sales data."
  - marketing:
      comment: "The marketing role provides access to the filtered view of the marketing data."
  - operations:
      comment: "The operations role provides access to the full view of the log data."

application_content:
  notebooks:
    - SALES_NB:
        main_file: ALL-DATA.ipynb
        roles: [sales]
        comment: Accessible to sales and app owners, references full view of the sales data

    - MARKETING_NB:
        main_file: FILTERED.ipynb
        roles: [marketing] #
        comment: Accessible to marketing and app owners, references filtered view of the marketing data

shared_content:
  databases:
    - my_database:
        schemas:
          - my_schema:
              roles: [] # Accessible to app owners
              tables:
                - sales_table:
                    roles: [sales] # Accessible to sales, app owners
                - marketing_table:
                    roles: [marketing] # Accessible to marketing, app owners
                - customer_table:
                    roles: [sales,marketing] # Accessible to sales and marketing, app owners
                - logs_table:
                    roles: [operations] # Accessible to operations and app owners
              views:
                - sales_view:
                    roles: [sales]   # Accessible to sales and app owners
                - marketing_view:
                    roles: [marketing] # Accessible to marketing and app owners
                - customer_view:
                    roles: [sales,marketing] # Accessible to sales, marketing, and app owners
                - operations_view:
                    roles: [operations] # Accessible to operations and app owners
Copy

その後、コンシューマーがアプリをインストールすると、ノートブック、テーブル、ビューの両方にアクセスできるようになります。

運用ビューをサポートチームと共有するには、operations アプリケーションロールをサポートチームの組織ロールに付与します。

GRANT APPLICATION ROLE customer_app.operations TO ROLE support_team_west;
Copy

support_team_west ロールを持つコンシューマーチームメンバーは logs テーブルを表示できますが、Snowsight の**Available Notebooks** タブのノートブックは表示できず、sales および customers のテーブルとビューにもアクセスできません。

salesビューを営業チームと共有するには、sales アプリケーションロールを営業組織のロールに付与します。

GRANT APPLICATION ROLE customer_app.sales TO ROLE sales_team_east;
Copy

sales_team_east ロールを持つコンシューマーチームのメンバーは、Snowsight の Available Notebooks タブのノートブックを表示できます。logs テーブルは表示できませんが、sales および customers のテーブルとビューにはアクセスできます。

For more information about how consumers share roles, see アプリへの共有アクセス.