ベアラートークンを使用して Databricks 以外のユーザー向けの受信者オブジェクトを作成する (オープン共有)
この記事では、Unity Catalog 対応の Databricks ワークスペースにアクセスできない Delta Sharing 受信者を作成し、ベアラー トークンを使用してそれらの受信者に安全に共有されたデータへのアクセス権を付与する方法について説明します。この認証フローは、OIDC トークン フェデレーション認証フローと共に、 オープン共有 と呼ばれます。
その仕組みは次のとおりです。
-
データ プロバイダーは、 Unity Catalog メタストアに受信者オブジェクトを作成します。
-
受信者オブジェクトを作成するときに、ベアラー トークン方式を選択すると、Databricks はトークン、トークンを含む資格情報ファイル、および受信者と共有するためのアクティブ化リンクを生成します。
受信者オブジェクトの認証タイプは
TOKEN
です。必要に応じて、トークンを更新および取り消すことができます。 -
受信者は、アクティベーションリンクにアクセスし、認証情報ファイルをダウンロードし、認証情報ファイルを使用して認証を行い、アクセス権を付与した共有に含まれるテーブルへの読み取りアクセス権を取得します。
OIDC フェデレーション フローは、この記事で説明するベアラー トークン フローの代替手段です。ベアラートークンフローよりもセキュリティと利便性に優れています。詳細については、「 Open ID Connect (OIDC) フェデレーションを使用して Delta Sharing 共有 (オープン共有) への認証を有効にする」を参照してください。
受信者を作成する
オープン共有の受信者を作成するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの CREATE RECIPIENT
SQL コマンドを使用できます。
必要なアクセス許可 : メタストア管理者、または共有するデータが登録されている Unity Catalog メタストアの CREATE_RECIPIENT
権限を持つユーザー。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, click New recipient.
-
Enter the Recipient name
-
For Recipient type, select Open.
-
Select Token.
-
(Optional) Set the Token lifetime expiration time (in seconds, minutes, hours, or day from recipient creation time). Leave Set expiration selected to set an expiration time. Clear the selection to allow the token to live indefinitely.
If you select Set expiration and leave the field blank, the token lifetime defaults to the recipient token lifetime value set in the metastore configuration. See Modify the recipient token lifetime. For information about changing the token lifetime and rotating tokens, see Manage recipient tokens.
-
(Optional) Enter a comment.
-
Click Create.
-
Copy the activation link.
Alternatively, you can get the activation link later. See Get the activation link.
-
(Optional) Create custom Recipient properties.
On the recipient Overview tab, click the
edit icon next to Recipient properties. Then add a property name (Key) and Value. For details, see Manage recipient properties.
Run the following command in a notebook or the Databricks SQL query editor:
CREATE RECIPIENT [IF NOT EXISTS] <recipient-name>
[COMMENT "<comment>"];
You can also add custom properties for the recipient. For details, see Manage recipient properties.
Run the following command using the Databricks CLI.
databricks recipients create <recipient-name>
You can also add custom properties for the recipient. For details, see Manage recipient properties.
Output includes the activation_url
that you share with the recipient.
受信者は TOKEN
のauthentication_type
で作成されます。
受信者を作成するときに、受信者のアクセスを制限された IP アドレスのセットに制限するオプションがあります。また、既存の受信者に IP アクセスリストを追加することもできます。「IP アクセス リストを使用して Delta Sharing 受信者のアクセスを制限する (オープン共有)」を参照してください。
アクティベーションリンクを取得する
新しい受信者のアクティベーションリンクを取得するには、カタログ エクスプローラー、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリー エディターの DESCRIBE RECIPIENT
SQL コマンドを使用できます。
受信者が既に資格情報ファイルをダウンロードしている場合、アクティベーションリンクは返されず、表示されません。
必要な権限 : メタストア管理者、 USE RECIPIENT
権限を持つユーザー、または受信者オブジェクトの所有者。
- Catalog Explorer
- SQL
- CLI
-
In your Databricks workspace, click
Catalog.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, click Recipients, and select the recipient.
-
On the recipient details page, copy the Activation link.
Run the following command in a notebook or the Databricks SQL query editor.
DESCRIBE RECIPIENT <recipient-name>;
Output includes the activation_link
.
Run the following command using the Databricks CLI.
databricks recipients get <recipient-name>
Output includes the activation_url
.
受信者に共有へのアクセス権を付与する
受信者を作成し、 共有を作成したら、その共有へのアクセス権を受信者に付与できます。
受信者に共有アクセス権を付与するには、Catalog Explorer、Databricks Unity Catalog CLI、または Databricks ノートブックまたは Databricks SQL クエリエディターの GRANT ON SHARE
SQL コマンドを使用できます。
必要な権限 : 次のいずれかです。
- メタストア管理者。
- 共有オブジェクトと受信者オブジェクト ((
USE SHARE
+SET SHARE PERMISSION
) または共有の所有者) および (USE RECIPIENT
または受信者の所有者) の両方に対する委任されたアクセス許可または所有権。
手順については、「 Delta Sharing データ共有へのアクセスを管理する (プロバイダー向け)」を参照してください。
受信者に接続情報を送信する
共有しているデータへのアクセス方法を受信者に知らせる必要があります。安全なチャンネルを使用して、 アクティベーションリンク とその 使用手順へのリンクを共有します。
資格情報ファイルは一度だけダウンロードできます。受信者は、ダウンロードした資格情報をシークレットとして扱い、組織外で共有してはなりません。資格情報が安全でない方法で処理された可能性があるという懸念がある場合は、 受信者の資格情報 をいつでもローテーションできます。受信者の安全なアクセスを確保するための資格情報の管理の詳細については、「 トークンのセキュリティに関する考慮事項」を参照してください。
受信者トークンの管理
オープン共有ベアラー トークン フローを使用して受信者とデータを共有している場合は、その受信者のトークンをローテーションする必要がある場合があります。トークンのローテーションは、既存のトークンを期限切れに設定し、新しいトークンとアクティベーションURLに置き換えることで構成されます。
次の状況では、受信者のトークンをローテーションし、新しいアクティベーションURLを生成する必要があります。
- 既存の受信者トークンの有効期限が近づいたとき。
- 受信者がアクティベーションURLを紛失した場合、または侵害された場合。
- 受信者が資格情報をダウンロードした後で、資格情報が破損、紛失、または侵害された場合。
- メタストアの受信者トークンの有効期間を変更する場合。「受信者トークンの有効期間を変更する」を参照してください。
トークンのセキュリティに関する考慮事項
受信者は、常に最大で 2 つのトークン (アクティブなトークンとローテーションされたトークン) を持つことができます。 ローテーションされたトークンは、有効期限が切れ、アクティブなトークンに置き換えられるように設定されたトークンです。ローテーションされたトークンの有効期限が切れるまで、トークンを再度ローテーションしようとするとエラーが発生します。
受信者のトークンをローテーションする場合、必要に応じて、既存の受信者トークン (つまり、ローテーションするトークン) の有効期限が切れるまでの秒数に --existing-token-expire-in-seconds
を設定できます。値を 0
に設定すると、既存の受信者トークンはすぐに期限切れになります。
Databricks では、受信者が 2 つのアクティブなトークンを持つ時間を最小限に抑えながら、受信者の組織が新しいアクティブ化 URL にアクセスする時間を与える比較的短い期間に --existing-token-expire-in-seconds
を設定することをお勧めします。既存の受信者トークンが侵害された疑いがある場合は、Databricks では、すぐに期限切れにすることを強制することをお勧めします。
受信者の既存のアクティベーション URL に一度もアクセスされていない場合、既存のトークンをローテーションすると、そのアクティベーション URL は無効になり、新しいアクティベーション URL に置き換えられます。
すべての受信者トークンの有効期限が切れている場合、トークンをローテーションすると、既存のアクティベーションURLが新しいURLに置き換えられます。 Databricks では、トークンの有効期限が切れた受信者を速やかにローテーションまたは削除することをお勧めします。
受信者のアクティベーションURLが誤って間違った人に送信されたり、安全でないチャンネルを介して送信されたりした場合は、 Databricks 次のことをお勧めします。
- 共有への受信者のアクセスを取り消します。
- 受信者を回転させ、
--existing-token-expire-in-seconds
を0
に設定します。 - 新しいアクティベーションURLを、安全なチャンネルを介して目的の受信者と共有します。
- アクティベーション URL にアクセスしたら、受信者に共有へのアクセス権を再度付与します。
極端な状況では、受信者のトークンをローテーションする代わりに、受信者 をドロップ して再作成できます。
受信者のトークンをローテーションする
受信者のトークンをローテーションするには、カタログエクスプローラーまたは Databricks Unity Catalog CLIを使用できます。
必要な権限 : 受信者オブジェクトの所有者。
- Catalog Explorer
- CLI
-
In your Databricks workspace, click
Catalog.
-
In the left pane, expand the Delta Sharing menu and select Shared by me.
-
At the top of the Catalog pane, click the
gear icon and select Delta Sharing.
Alternatively, from the Quick access page, click the Delta Sharing > button.
-
On the Shared by me tab, click Recipients, and select the recipient.
-
On the Details tab, under Token Expiration, click Rotate.
-
On the Rotate token dialog, set the token to expire either immediately or for a set period of time. For advice about when to expire existing tokens, see Security considerations for tokens.
-
Click Rotate.
-
On the Details tab, copy the new Activation link and share it with the recipient over a secure channel. See Get the activation link.
-
Run the following command using the Databricks CLI. Replace the placeholder values:
<recipient-name>
: the name of the recipient.<expiration-seconds>
: The number of seconds until the existing recipient token should expire. During this period, the existing token will continue to work. A value of0
means the existing token expires immediately. For advice about when to expire existing tokens, see Security considerations for tokens.
Bashdatabricks recipients rotate-token \
<recipient-name> \
<expiration-seconds> -
Get the recipient’s new activation link and share it with the recipient over a secure channel. See Get the activation link.
受信者トークンの有効期間を変更する
Unity Catalog メタストアのデフォルト受信者トークンの有効期間を変更する必要がある場合は、カタログ エクスプローラーまたは Databricks Unity Catalog CLIを使用できます。
既存の受信者の受信者トークンの有効期間は、メタストアのデフォルト受信者トークンの有効期間を変更しても自動的に更新されません。 新しいトークンの有効期間を特定の受信者に適用するには、トークンをローテーションする必要があります。「受信者トークンの管理」を参照してください。
必要な権限 : アカウント管理者。
- Catalog Explorer
- CLI
- Log in to the account console.
- In the sidebar, click
Catalog.
- Click the metastore name.
- Under Delta Sharing recipient token lifetime, click Edit.
- Enable Set expiration.
- Enter a number of seconds, minutes, hours, or days, and select the unit of measure.
- Click Save.
If you disable Set expiration, recipient tokens do not expire. Databricks recommends that you configure tokens to expire.
Run the following command using the Databricks CLI. Replace 12a345b6-7890-1cd2-3456-e789f0a12b34
with the metastore UUID, and replace 86400
with number of seconds before the recipient token expires. If you set this value to 0
, recipient tokens do not expire. Databricks recommends that you configure tokens to expire.
databricks metastores update \
12a345b6-7890-1cd2-3456-e789f0a12b34 \
--delta-sharing-recipient-token-lifetime-in-seconds 86400