ローカルアプリケーション用のSnowflake OAuth の使用¶
This topic describes the preferred authentication method for local applications, including desktop applications and local scripts.
Snowflake OAuth is implemented by creating a security integration that defines an interface between Snowflake as the OAuth authorization server and the application that is authenticating on behalf of a user by using the OAuth authorization code flow. Snowflake OAuth is a strong authentication option because the application doesn't have to store or manage secrets, and you don't have to configure a third-party identity provider like External OAuth.
To simplify how a local application uses Snowflake OAuth to authenticate, your account has a built-in
security integration called SNOWFLAKE$LOCAL_APPLICATION. Because the security integration already exists, if a local application
uses a Snowflake client like the Python driver or Snowflake CLI, the application can authenticate to Snowflake by setting a property or
parameter of the client. No further set up is required. The built-in integration also simplifies the setup for local applications that call
the OAuth endpoints directly rather than use a Snowflake client.
管理者は SNOWFLAKE$LOCAL_APPLICATION 統合のパラメーターを変更して、 OAuth アクセストークンとリフレッシュトークンの有効期間を指定するなど、動作を調整します。
ローカルアプリケーション用のSnowflake OAuth には、次の追加の利点があります。
Unlike user-created Snowflake OAuth integrations, in-role session switching is supported.
これは、現在ユーザー認証のためにのみパスワードを使用しているアプリケーションに対してそのまま代わりになります。Snowflakeは 単一要素パスワードを非推奨 にしているので、ローカルアプリケーション用のSnowflake OAuth は、多くのセットアップを必要とせずに、より安全な形式の認証を使用するための手段を提供します。
注釈
SNOWFLAKE$LOCAL_APPLICATION のセキュリティ統合はすべてのアカウントに徐々に展開されています。この組み込み統合がアカウントに存在するかどうかを確認するには、次のコマンドを実行します。
SHOW SECURITY INTEGRATIONS LIKE 'SNOWFLAKE$LOCAL_APPLICATION';
Snowflake OAuth 統合の構成¶
組み込み SNOWFLAKE$LOCAL_APPLICATION セキュリティ統合はシステムによって所有されていますが、セキュリティ管理者(つまり、 SECURITYADMIN システムロールを付与されたユーザー)が構成できます。
セキュリティ管理者は、セキュリティ統合の次のパラメーターを構成できます。
パラメーター |
説明 |
|---|---|
|
統合を有効にするかどうかを制御します。統合が無効になっている場合、ローカルアプリケーションは別の認証方法を使用する必要があります。 |
|
Controls whether the authorization server issues refresh tokens. |
|
リフレッシュトークンの有効期間を設定します。 |
|
Controls whether the authorization server issues single-use refresh tokens. |
|
アクセストークンの有効期間を設定します。 |
For example, to modify the built-in security integration so that the authorization server starts issuing single-use refresh tokens, run the following commands:
USE ROLE SECURITYADMIN;
ALTER SECURITY INTEGRATION SNOWFLAKE$LOCAL_APPLICATION
SET OAUTH_SINGLE_USE_REFRESH_TOKENS_REQUIRED = TRUE;
これらのパラメーターの設定の詳細については、 ALTER SECURITY INTEGRATION をご参照ください。
ログイン頻度の制御¶
When OAUTH_ISSUE_REFRESH_TOKENS = TRUE, applications can use refresh tokens to obtain new access tokens without prompting users to log
in again. Users only need to re-authenticate when the refresh token expires after the duration that is specified by the
OAUTH_REFRESH_TOKEN_VALIDITY parameter.
Snowflake OAuth を使用するためのローカルアプリケーションの設定¶
This section provides the details a developer needs to configure a local application to authenticate with Snowflake OAuth. The following types of local applications can authenticate by using the built-in integration:
PythonドライバーやSnowflake CLI などのSnowflakeクライアントを使用するローカルアプリケーション。Snowflakeクライアントを使用するアプリケーション をご参照ください。
Snowflakeクライアントを使用せずに、 OAuth 認証エンドポイントとトークンエンドポイントに対して直接 REST リクエストを行うローカルアプリケーション。OAuth エンドポイントを直接呼び出すアプリケーション をご参照ください。
Snowflakeクライアントを使用するアプリケーション¶
When a local application uses a Snowflake client like the Snowflake ODBC driver, it can authenticate with Snowflake OAuth by setting the
authenticator connection option to oauth_authorization_code. Additional development work isn't required.
前提条件¶
With Snowflake OAuth for local applications, the Snowflake client must be able to open the user's web browser. For this reason, both the Snowflake client and the local application that uses it must be installed on the user's computer. Snowflake OAuth for local applications doesn't work if the Snowflake client is used by code that runs on a server.
サポートされているクライアント¶
ローカルアプリケーションは、次のSnowflakeクライアントを使用してローカルアプリケーション用のSnowflake OAuth で認証できます。
クライアント |
必要最小バージョン |
必要な構成 |
|---|---|---|
.NET |
v4.8.0 |
接続文字列で |
Go |
v1.14.1 |
接続構成で |
JDBC |
v3.24.1 |
ドライバーの接続文字列で |
Node.js |
v2.1.0 |
接続オプションで |
ODBC |
v3.9.0 |
|
Python |
v3.16.0 |
|
Snowflake CLI |
v3.8.1 |
接続定義に |
SnowSQL |
v1.4.0 |
構成ファイルに |
OAuth エンドポイントを直接呼び出すアプリケーション¶
Your local application can use Snowflake OAuth by making requests to the authorization endpoint and token endpoint of Snowflake as the authorization server. You don't need to use a Snowflake client. The application sends a request to Snowflake's authorization endpoint to authenticate the user and receive an authorization code, and then sends a request to the token endpoint to exchange that code for an access token.
Snowflakeの認証エンドポイントとトークンエンドポイントに REST リクエストを行うことの詳細については、 OAuth エンドポイントを呼び出す をご参照ください。
リクエスト要件¶
認証エンドポイントとトークンエンドポイントに対するアプリケーションの REST リクエストは、以下の要件に準拠している必要があります。
The redirect URL in the request to the authorization endpoint must be
http://127.0.0.1[:port][/path]. That is, your local application must be listening on a loopback address for the authorization code that is returned by Snowflake as the authorization server.認証およびトークンエンドポイントへのリクエストは、コード交換のための証明キー(PKCE)を実装する必要があります。詳細については、 コード交換の証明キー をご参照ください。
When calling the token endpoint to exchange an authorization code for an access token, the application must provide the proper client ID and client secret. This requirement varies slightly depending on how you choose to send these client credentials:
リクエストヘッダーでクライアント認証情報を送信する場合、クライアント ID は
LOCAL_APPLICATIONで、クライアントシークレットはLOCAL_APPLICATIONである必要があります。POST 本文でクライアント認証情報を送信する場合、クライアント ID は
LOCAL_APPLICATIONである必要があります。組み込みの統合はローカルアプリケーションをパブリッククライアントとして構成するため、 POST 本文でクライアント ID をclient_id=LOCAL_APPLICATIONとして提供する場合、クライアントシークレットは必要ありません。
使用上の注意¶
Every account has a SNOWFLAKE$LOCAL_APPLICATION integration, so this integration isn't replicated. The
configuration of the built-in integration is unique to each account.