Snowflakeセッションおよびセッションポリシー

このトピックでは、Snowflakeセッションとセッションポリシーについて説明し、アカウントまたはユーザーレベルでセッションポリシーを構成する手順について説明します。

Snowflakeセッション

セッションは、ユーザーがSnowflakeに接続し、Snowflakeプログラムクライアント、または Snowsight を使用して正常に認証されたときに開始されます。セッションは、IDプロバイダー(IdP)セッションから独立しています。Snowflakeセッションの有効期限が切れても、 IdP セッションがアクティブなままの場合、ユーザーは認証情報を再度入力せずにSnowflakeにログインできます(つまり、サイレント認証)。

By default, a session is maintained indefinitely with continued user activity. After a period of inactivity in the session, known as the idle session timeout, the user must authenticate to Snowflake again. The default idle session timeout is four hours for non-UI (programmatic) sessions and 18 hours for UI sessions (if opted in to BCR-2139). The session policy can modify the idle session timeout period from a minimum of 5 minutes to a maximum of 24 hours.

A session policy can also enforce a maximum session lifespan, which ends the session after a set duration regardless of activity. The configurable range is 0 minutes to 30 days, where a value of 0 means no maximum lifespan is enforced. By default, no maximum lifespan is enforced. These session timeouts apply to the following:

Snowflakeは、可能であれば既存のセッションを再利用し、セッションが不要になったときにSnowflakeへの接続を閉じることをお勧めします。

Snowsight セッション期限切れとログアウトの動作

  • A Snowsight session remains active as long as the user is interacting with the application, has not exceeded the configured idle session timeout, and has not reached the maximum session lifespan (if configured).

  • The session idle timeout is controlled by your organization's session policy. The default idle timeout is four hours (or 18 hours if opted in to BCR-2139). If there is no activity for longer than this period, the session will expire and you will be logged out automatically.

  • A session policy can also enforce a maximum session lifespan. If configured, the session expires after the specified duration regardless of activity. By default, no maximum lifespan is enforced.

  • In addition to idle timeout and maximum lifespan, session persistence is also affected by authentication cookies:

    • ほとんどの場合、ブラウザーを閉じて再度開くと、アイドルタイムに関わらず Snowsight セッションは終了します。

    • 認証クッキーの有効期限が切れた場合(通常は24時間後)、セッションタイムアウトより長くアイドル状態でなくても、再度ログインする必要があります。

  • ネットワーク接続が切れた場合、または許可されていないネットワークから Snowsight にアクセスしようとした場合、セッションが閉じられ、ログアウトされる可能性があります。

  • 何らかの理由でセッションが閉じられると、そのセッションに関連付けられた実行中のクエリやジョブは、短い遅延後に(通常は数分以内)終了します。

注釈

Session expiration can occur due to idle timeout, maximum session lifespan, cookie expiration, browser restarts, or network policy violations. Closing your browser or being inactive for an extended period may require you to log in again, even if you have not reached the configured idle timeout.

セッションの使用状況の監視

Snowsight または SQL 表示を使用して、アクティブなセッションとセッションの使用状況を監視できます。自分のセッションを表示するか、SESSIONSを表示するアクセス権を持つロールを使用して、自分のアカウントのセッションを表示することができます。ACCOUNT_USAGE スキーマ SNOWFLAKE データベースロール をご参照ください。

SQL:

共有 SNOWFLAKE データベースの ACCOUNT USAGE スキーマの SESSIONS ビューをクエリして、セッションの使用状況をモニターします。

Snowsight:

ナビゲーションメニューで、 Governance & security » Network policies を選択してから、 Sessions タブを選択します。セッションID、ユーザー名、開始時間、セッションで使用されているクライアントドライバー、クライアントのネットアドレス、認証コードを確認できます。開始時間にカーソルを合わせると、セッションが開始された正確な日付と時刻(お住まいの地域のタイムゾーン)が表示されます。

セッションポリシー

セッションポリシーは、 アイドル セッションタイムアウト期間を分単位で定義し、デフォルトのアイドルタイムアウト値を上書きするオプションを提供します。タイムアウト期間は、Snowflakeへの認証が成功すると始まります。セッションポリシーの設定可能な最小アイドルタイムアウト値は 5 分です。

If a session policy is not set, Snowflake uses a default value of 240 minutes (four hours) for non-UI (programmatic) sessions. For Snowsight sessions, the default is 1080 minutes (18 hours) if opted in to BCR-2139, or 240 minutes (four hours) otherwise.

セッションが期限切れになった場合、ユーザーはSnowflakeに対して再度認証する必要があります。ただし、Snowflakeは、 カスタムログアウトエンドポイント で定義された設定を強制しません。

The session policy can be set for an account or user with configurable idle timeout and maximum session lifespan values to address compliance requirements. If a user is associated with both an account and user-level session policy, the user-level session policy takes precedence. After the session policy is set on the account or user, Snowflake enforces the session policy.

There are two properties that govern the idle timeout behavior:

  • プログラムクライアントおよびSnowflakeクライアント用 SESSION_IDLE_TIMEOUT_MINS

  • SESSION_UI_IDLE_TIMEOUT_MINS の Snowsight。

A session policy can also define the maximum session lifespan, regardless of activity. When the maximum lifespan is reached, the user must authenticate again even if the session is still active. The configurable range is 0 to 43200 minutes (30 days).

If a session policy is set but a session lifespan is not defined, Snowflake uses a default value of 0, which means no maximum lifespan is enforced.

There are two properties that govern the maximum lifespan behavior:

  • SESSION_MAX_LIFESPAN_MINS for programmatic and Snowflake clients.

  • SESSION_UI_MAX_LIFESPAN_MINS for Snowsight.

詳細については、 セッションポリシーの管理 をご参照ください。

セッションポリシーにおけるセカンダリロール

ユーザーがSnowflakeに接続し、セッションが開始されると、ユーザーは USE SECONDARY ROLES コマンドで セカンダリロール をアクティブにすることができます。しかし、セキュリティ管理者として、個々のユーザー、ユーザーのグループ、またはアカウント全体が利用可能なセカンダリロールを管理したいと思うかもしれません。セカンダリロールを管理することで、セッションの間、ユーザーが利用できる権限のセットをスコープできるようになります。

このような管理ニーズを満たすために、セッションポリシーに ALLOWED_SECONDARY_ROLES プロパティを設定し、アカウントまたはアカウント内のユーザーにセッションポリシーを設定することができます。このプロパティは、セッションで有効化できるセカンダリ・ロールを制御します。このプロパティを空のリスト ALLOWED_SECONDARY_ROLES=() にセットすると、セッションのセカンダリ・ロールが無効になります。

例については、 セッションポリシーでセカンダリロールを指定する をご参照ください。

注釈

セッションポリシーで ALLOWED_SECONDARY_ROLES プロパティをセットすると、既存のセッションを含め、セカンダリロールの適用が直ちに開始されます。

セカンダリロールを制限するためにセッションポリシーを更新する前に、ワークロードの不要な中断を避けるために、ワークロードのスケジュールと各ワークロードのアクセス制御を考慮してください。

考慮事項

  • If a client supports the CLIENT_SESSION_KEEP_ALIVE option and the option is set to TRUE, the client preserves the Snowflake session as long as the connection to Snowflake is active. However, if a session policy with a maximum session lifespan is configured, the session still ends when that lifespan is reached, regardless of activity. If the option is set to FALSE, the session ends after the idle session timeout (four hours by default for programmatic sessions). When possible, avoid using this option since it can result in many open sessions and place a greater demand on resources, which can lead to a performance degradation.

  • CLIENT_SESSION_KEEP_ALIVE_HEARTBEAT_FREQUENCY パラメーター使用して、クライアントがセッションのトークンを更新しようとする間隔の秒数を指定できます。DDL および DML ステートメントの実行など、Snowflakeオブジェクトが引き続き使用されると、ウェブインターフェイスセッションを更新できます。Snowflakeは、30秒ごとにこの動作をチェックします。

  • 新しいワークシートを作成するか、既存のワークシートを開くと、確立されたユーザーセッションが引き続き使用されますが、アイドルセッションのタイムアウトは0にリセットされます。

制限事項

将来の付与:

セッションポリシーに対する権限の 将来の付与 はサポートされていません。

回避策として、カスタムロールに APPLYSESSION POLICY 権限を付与して、そのロールがユーザーまたはSnowflakeアカウントにセッションポリシーを適用できるようにします。