# 已验证访问

身份验证访问允许您发布内容，同时要求任何想要查看内容的访问者进行身份验证。启用后，GitBook 会让您的身份验证提供方负责处理谁可以访问内容。

<figure><img src="/files/0710cefed65944f46d32306d933dc7363f8ae76d" alt="A screenshot showing a login screen for docs behind authenticated access"><figcaption><p>为您发布的文档添加登录功能。</p></figcaption></figure>

### 使用场景

身份验证访问的常见使用场景包括：

* 发布敏感的产品文档，这些文档应仅对付费客户、销售潜在客户或合作伙伴可访问。
* 发布内部知识库内容，这些内容应仅对贵公司的员工可访问。

### 工作原理

在设置身份验证访问时，您可以选择两种方法：

1. 安装我们的某个身份验证集成——我们目前支持 Okta、Azure 和 Auth0。我们 **强烈建议** 如果您使用的是我们支持的身份验证提供方，请选择此选项。
2. 创建并托管您自己的服务器来处理身份验证。可以使用许多不同的技术，但由您来编码并维护您选择的解决方案。

### 内置登录和登出 URL

GitBook 为您发布的网站提供内置的登录和登出 URL：

* `<publishedSiteURL>/~gitbook/auth/login`
* `<publishedSiteURL>/~gitbook/auth/logout`

在任何需要登录链接的地方使用登录 URL，例如您网站页眉中的链接。

当访问者打开登录 URL 时，GitBook 会将他们重定向到为该站点配置的身份验证后端。这适用于集成后端和自定义后端。

GitBook 还会添加一个 `location` 与访问者起始页面相匹配的查询参数。您的后端可以使用该值在登录后将他们送回同一页面。

使用登出 URL 可将访问者从其 GitBook 会话中登出。

进入 [启用经过身份验证的访问](/docs/documentation/zh/zhan-dian-fang-wen/authenticated-access/enabling-authenticated-access.md) 以开始为您的站点设置受保护访问。


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.com/docs/documentation/zh/zhan-dian-fang-wen/authenticated-access.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
