# 使用 Okta 创建数据源

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com/zh-cn/help/idea/llms.txt).

Procedure: 启用 数据库工具和 SQL 插件

此功能依赖于 数据库工具和 SQL 插件，该插件默认情况下在 IntelliJ IDEA 中绑定并启用。 如果相关功能不可用，请确保您没有禁用插件。

> **Note:**
> 没有 Ultimate 订阅时，数据库工具和 SQL 的功能支持在 IntelliJ IDEA 中受限。

1. 按 `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) 打开设置，然后选择  `插件` 。

2. 找到  数据库工具和 SQL  插件并点击   启用  。

Procedure: 官方文档

* 有关 Amazon Redshift 的完整信息，请参阅 [官方文档](https://docs.aws.amazon.com/redshift/index.html)。

* 更多版本的 Amazon Redshift JDBC 驱动程序，请参阅 [官方 JDBC 驱动程序下载](https://docs.aws.amazon.com/redshift/latest/mgmt/jdbc20-download-driver.html)。

* [Amazon Redshift 通过多重身份验证进行身份联合](https://aws.amazon.com/blogs/big-data/amazon-redshift-identity-federation-with-multi-factor-authentication/)

在本教程中，我们将创建一个 Amazon Redshift 数据源，将其配置为使用 Okta 身份提供者进行 SAML 身份验证，并运行与数据库的测试连接。

有关集成与连接设置的更多信息，请参阅以下页面： [Okta 文档中的身份验证](https://help.okta.com/oie/en-us/content/topics/security/security_at_okta.htm)。

## 前提

* 您的 Amazon Redshift 仪表板中必须有一个 Amazon Redshift 集群。 有关 Amazon Redshift 集群的更多信息，请参阅 [《Amazon Redshift 入门指南》](https://docs.aws.amazon.com/redshift/latest/gsg/getting-started.html)

* [AWS SSO](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html) 必须为您的 AWS 账户启用。

* 您的 AWS 账户必须 [与您的 Okta 账户关联](https://docs.aws.amazon.com/singlesignon/latest/userguide/tutorials.html)。

* 在使用 Okta SSO 身份验证连接 Amazon Redshift 数据库之前，请先安装并设置 [Okta Verify](https://help.okta.com/en-us/content/topics/mobile/okta-verify-overview.htm) 应用程序。 所需软件设置完毕并准备就绪后，需要在 IntelliJ IDEA 中创建一个 Amazon Redshift 数据源，并将其配置为使用 Okta SSO 身份验证。

Procedure: 创建数据源

1. 在   数据库   工具窗口中，点击工具栏上的 ![新建图标](https://resources.jetbrains.com/help/img/idea/2026.3/app.expui.general.add.svg)   新建   并导航到  `数据源 | Amazon Redshift` 。

![选择 Amazon Redshift 数据源](https://resources.jetbrains.com/help/img/idea/2026.3/create_new_data_source_redshift.png)

2. 请检查连接设置区域底部是否有一个   下载缺少的驱动程序文件   链接。 点击此链接下载与数据库交互所需的驱动程序。 如需直接下载链接，请参考 [JetBrains JDBC drivers](https://www.jetbrains.com/zh-cn/datagrip/jdbc-drivers/)页面。

![下载缺失的驱动文件链接](https://resources.jetbrains.com/help/img/idea/2026.3/db_connection_download_missing_drivers_link.png)

3. 请指定数据库连接详情。

1.

在   主持人   字段中，输入用于连接到您的 Redis 账户的 URL。 例如，  `examplecluster.abc123xyz789.us-west-2.redshift.amazonaws.com` 。

2.

在   端口   字段中，键入端口号。 在本例中，它是  `5439` 。

3.

在   用户   字段中，输入用于登录 Okta 账户的电子邮件地址。

4.

在   密码   字段中，输入 Okta 账户密码。

5.

在   数据库  字段中，输入您要连接的数据库名称。 在本例中，数据库是  `dev` 。

6.

在   JDBC URL   字段中自动生成的 URL 末尾，添加  `?`  以及用  `&`  分隔的以下属性:

* `plugin_name=<credentials_provider_class_name>` : 用于身份验证的 [基于 SAML 的凭据提供程序插件](https://docs.aws.amazon.com/redshift/latest/mgmt/options-for-providing-iam-credentials.html#using-credentials-provider-plugin)。 在本教程中，我们将使用可与基于 SAML 的身份提供者配合使用的浏览器 SAML 插件: `plugin_name=com.amazon.redshift.plugin.BrowserSamlCredentialsProvider` 。

* `login_url=<login_url>` : 身份提供者 URL。 在我们的示例中，它是指 Okta 登录页面的 URL： `login_url=https://example.okta.com/app/example_1/abc012/sso/saml` 。

因此，我们的 JDBC URL 如下:

`jdbc:redshift:iam://examplecluster.abc123xyz789.us-west-2.redshift.amazonaws.com:5439/dev?plugin_name=com.amazon.redshift.plugin.BrowserSamlCredentialsProvider&login_url=https://example.okta.com/app/example_1/abc012/sso/saml`

或者，在   URL   字段中键入 JDBC URL。 通常使用的 URL 如下：

* 格式: `jdbc:redshift:iam://<cluster_name>.<additional_unique_identifier>.<cluster_region>.redshift.amazonaws.com:<port_number>/dev?plugin_name=<plugin_name>&login_url=<login_url>&user=<username>&password=<password>`

* 示例： `jdbc:redshift:iam://examplecluster.abc123xyz789.us-west-2.redshift.amazonaws.com:5439/dev?plugin_name=com.amazon.redshift.plugin.BrowserSamlCredentialsProvider&login_url=https://example.okta.com/app/example_1/abc012/sso/saml&user=<my_username>&password=<dummy_password>`

4. 点击连接详细信息区域底部的   测试连接   链接，以启动与数据库的测试连接。

![测试连接链接](https://resources.jetbrains.com/help/img/idea/2026.3/db_test_connection_link.png)

5. 在浏览器中打开的 Okta 网站上，输入用户凭据并登录 Okta 账户。

![在 Okta 网站登录 Okta 账户](https://resources.jetbrains.com/help/img/idea/2026.3/db_redshift_okta_log_in_to_okta.png)

6. Okta 确认身份后，返回 IntelliJ IDEA。

![来自 Okta 的身份确认消息](https://resources.jetbrains.com/help/img/idea/2026.3/db_redshift_okta_verified.png)

7. 在 IDE 中，点击   OK   以保存新的数据源。

![数据库连接详情](https://resources.jetbrains.com/help/img/idea/2026.3/db_connection_details_redshift_okta.png)

## See also

### 参考

[数据源及其元素](database-tool-window.html#icons-for-data-sources-and-their-elements) [数据源和驱动程序对话框](data-sources-and-drivers-dialog.html)

### 工具 Windows

[数据库工具窗口](database-tool-window.html)

