> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/publish/site-audience/authenticated-access/setting-up-okta.md).

# 设置 Okta

为你的文档访客设置 Okta 登录界面

{% hint style="warning" %}
本指南将带你设置文档的受保护登录页面。在阅读本指南之前，请先完成以下流程： [启用经过身份验证的访问](https://gitbook.com/docs/documentation/zh/publish/site-audience/authenticated-access/enabling-authenticated-access.md).
{% endhint %}

要使用 Okta 设置带有身份验证访问的 GitBook 站点，流程如下：

{% stepper %}
{% step %}
**创建一个新的 Okta 应用**

从你的 Okta 仪表板创建一个 Okta 应用。
{% endstep %}

{% step %}
**安装并配置 Okta 集成**

安装 Okta 集成并添加所需配置。
{% endstep %}

{% step %}
**配置 Okta 以支持自适应内容（可选）**

配置 Okta 以配合 GitBook 中的自适应内容使用。
{% endstep %}
{% endstepper %}

### 创建一个新的 Okta 应用

首先，登录 Okta 平台（管理员版本），然后通过点击左侧边栏中的 Applications 按钮创建一个新的应用集成（或使用现有的集成）。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-15a0963cdfe65f88e06dfbd020fab67dd9a105b8%2F25_04_10_setting_up_okta_1.png?alt=media" alt="An Okta screenshot showing the create app integration screen"><figcaption></figcaption></figure>

点击 Create App Integration，并将 OIDC - OpenID Connect 选择为登录方式。然后将 Web Application 选择为应用类型。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-9dba9a1d00d7ca1812b897076312520db4407876%2F25_04_10_setting_up_okta_2.png?alt=media" alt="An Okta screenshot showing the integration setup"><figcaption></figcaption></figure>

为其起一个合适的名称，不要更改该页面上的任何其他设置。对于分配项，选择相应的复选框。点击 Save。

在下一个屏幕中，复制 Client ID 和 Client Secret。通过点击右上角的下拉菜单，复制电子邮件地址下方的 Okta Domain。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-8576aa9b2bce6cfcafe24c004247b371857f0da5%2F25_04_10_setting_up_okta_3.png?alt=media" alt="An Okta screenshot showing where to copy client credentials"><figcaption></figcaption></figure>

我们需要这些值来配置 Okta 集成。

### 安装并配置 Okta 集成

前往你要发布的网站中的 Integrations 选项卡，找到 Okta 集成。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-ea7399c8ff86c4770267835357f74144f3c10785%2F25_04_10_setting_up_okta_5.png?alt=media" alt="A GitBook screenshot showing the site settings page"><figcaption></figcaption></figure>

在你的网站上安装该集成。

在站点上安装后，你会看到一个页面，要求你输入 Client ID、Okta Domain 和 Client Secret。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-77eb7d4059b6a727e86d202e5bffc3706b097a25%2F25_04_10_setting_up_okta_6.png?alt=media" alt="A GitBook screenshot showing the Okta credentials modal"><figcaption></figcaption></figure>

对于 Client ID、Okta Domain（如有，请移除 `https://`前缀）和 Client Secret，请粘贴从 Okta 信息中心复制的值。

点击 Save。

复制模态窗口中显示的 URL，并将其输入到 Okta 中的 Sign-In 重定向 URI（如下图所示）。点击 Save。

<figure><img src="https://2111890564-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNkEGS7hzeqa35sMXQZ4X%2Fuploads%2Fgit-blob-1a13ba3a8c7a1948b29a62826d6d97e13a9b0a41%2F25_04_10_setting_up_okta_4.png?alt=media" alt="An Okta screenshot showing the sign-in redirect URI configuration"><figcaption></figcaption></figure>

现在，在 GitBook 中关闭集成弹窗，然后点击 Manage site 按钮。前往 **受众**，选择 **经过身份验证的访问**，并选择 Okta 作为后端。然后，点击 **更新受众**。前往站点页面并点击 **发布**。\
\
现在，站点已发布，并由 Okta 应用控制经过身份验证的访问。要试用此功能，请点击 Visit。系统会要求你使用 Okta 登录，以确认站点已通过 Okta 发布并启用了经过身份验证的访问。

### 配置 Okta 以支持自适应内容（可选）

要在带有身份验证访问的 GitBook 站点中启用自适应内容，你需要配置你的 Okta 应用，使其在身份验证令牌中包含相关的用户数据作为声明。

声明是嵌入在发送给 GitBook 的令牌中的键值对。这些声明可用于根据用户的角色、套餐、位置或任何其他标识属性动态定制文档内容。

Okta 支持多种类型的声明：

* **标准声明**\
  这些是常见的声明（例如 `email`, `、`或 `groups`），可能默认包含在内，但通常需要在令牌配置中明确添加，才能确保其始终可用。
* **自定义声明**\
  你可以在 Okta 中使用 [自定义用户属性](https://help.okta.com/en-us/content/topics/users-groups-profiles/usgp-add-custom-user-attributes.htm) 或基于表达式的逻辑来定义自定义声明。借助这些声明，你可以传递高度特定的值，例如套餐等级、账户 ID 或内部团队标记。
* **作为声明的群组**\
  你也可以将 Okta 群组作为声明传递；在定义“企业用户”或“测试用户”等受众细分时，这尤其有用。你可以在授权服务器的声明配置中筛选和映射这些群组。

要在 Okta 中添加或自定义声明：

1. 打开你的 Okta 管理控制台。
2. 前往 **Security > API > Authorization Servers**.
3. 编辑用于你的 GitBook 站点的授权服务器。
4. 在 **声明** 标签页中，添加规则，将所需声明包含在令牌中。
5. 确保你的 GitBook 站点能够正确读取并映射这些声明。

将声明传递到 GitBook 后，请按照 [调整你的内容](https://gitbook.com/docs/documentation/zh/publish/adaptive-content/adapting-your-content.md) 中的步骤，定义向哪些用户显示哪些内容。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/publish/site-audience/authenticated-access/setting-up-okta.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
