로컬 애플리케이션에 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는 :doc:`단일 요소 비밀번호 사용을 중단</user-guide/security-mfa-rollout>`합니다. 따라서 로컬 애플리케이션용 Snowflake OAuth는 많은 설정을 할 필요 없이 보다 안전한 인증 형식을 사용할 수 있는 경로를 제공합니다.

참고

SNOWFLAKE$LOCAL_APPLICATION 보안 통합은 모든 계정에 느리게 배포되고 있습니다. 계정에 이 기본 제공 통합이 있는지 확인하려면 다음 명령을 실행합니다.

SHOW SECURITY INTEGRATIONS LIKE 'SNOWFLAKE$LOCAL_APPLICATION';
Copy

Snowflake OAuth 통합 구성하기

기본 제공 SNOWFLAKE$LOCAL_APPLICATION 보안 통합은 시스템에서 소유하지만 보안 관리자(즉, SECURITYADMIN 시스템 역할 권한이 부여된 사용자)가 구성할 수 있습니다.

보안 관리자는 보안 통합의 다음 매개 변수를 구성할 수 있습니다.

매개 변수

설명

ENABLED

통합의 활성화 여부를 제어합니다. 통합이 비활성화된 경우 로컬 애플리케이션은 다른 인증 방법을 사용해야 합니다.

OAUTH_ISSUE_REFRESH_TOKENS

Controls whether the authorization server issues refresh tokens.

OAUTH_REFRESH_TOKEN_VALIDITY

새로 고침 토큰의 유효 기간을 설정합니다.

OAUTH_SINGLE_USE_REFRESH_TOKENS_REQUIRED

Controls whether the authorization server issues single-use refresh tokens.

OAUTH_ACCESS_TOKEN_VALIDITY

액세스 토큰의 유효 기간을 설정합니다.

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;
Copy

이러한 매개 변수 설정에 대한 자세한 내용은 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:

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

연결 문자열에 :code:`authenticator=oauth_authorization_code`를 설정합니다.

Go

v1.14.1

연결 구성에 :code:`authenticator=oauth_authorization_code`를 설정합니다.

JDBC

v3.24.1

드라이버의 연결 문자열에 authenticator=:code:`oauth_authorization_code`를 설정합니다.

Node.js

v2.1.0

연결 옵션에 :code:`authenticator: ‘oauth_authorization_code’`를 설정합니다.

ODBC

v3.9.0

  • Linux 및 macOS의 경우 odbc.ini 파일에 :code:`authenticator=oauth_authorization_code`를 설정합니다.

  • Windows의 경우 ODBC Data Source Administrator 도구에서, Snowflake용 DSN을 편집하고 Authenticator를 :code:`oauth_authorization_code`로 설정합니다.

Python

v3.16.0

AUTHENTICATOR=OAUTH_AUTHORIZATION_CODEsnowflake.connector.connect() 함수에 전달합니다.

Snowflake CLI

v3.8.1

연결 정의에 authenticator = "OAUTH_AUTHORIZATION_CODE" 옵션을 추가합니다.

SnowSQL

v1.4.0

구성 파일에 authenticator = "OAUTH_AUTHORIZATION_CODE" 매개 변수를 추가합니다.

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(Proof Key for Code Exchange)를 구현해야 합니다. 자세한 내용은 PKCE(Proof Key for Code Exchange) 섹션을 참조하십시오.

  • 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를 :code:`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.