> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJlN2Q5YjUxMC0xNDhlLTQ0ZjctOGEyNi05MTIzYzhlZTEwZjAiLCJleHAiOjE3NzgyODc5NDQsImlhdCI6MTc3ODI4NzY0NH0.CX33_nGT2x3VSGessZHZUENDvEyYFL7SUTKiOphMePE
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 身份验证选项概述

> 了解 Fern 提供的不同身份验证选项

Fern 提供四种方式来对文档站点上的用户进行身份验证。

<CardGroup cols={2}>
  <Card title="密码保护" icon="fa-duotone fa-lock" href="/learn/docs/authentication/setup/password-protection">
    整个站点的共享密码或映射到角色的多个密码
  </Card>

  <Card title="SSO" icon="fa-duotone fa-user-check" href="/learn/docs/authentication/setup/sso">
    内部文档的企业凭据
  </Card>

  <Card title="JWT" icon="fa-duotone fa-key" href="/learn/docs/authentication/setup/jwt">
    与您的登录系统集成的自管理身份验证
  </Card>

  <Card title="OAuth" icon="fa-duotone fa-shield-halved" href="/learn/docs/authentication/setup/oauth">
    通过您的 OAuth 提供商的 Fern 托管身份验证
  </Card>
</CardGroup>

## 我应该使用哪种选项？

* **[密码保护](/learn/docs/authentication/setup/password-protection)** — 您需要通过共享密码进行快速访问控制（无需每用户账户）。支持映射到角色的多个密码，用于[基于角色的访问控制](/learn/docs/authentication/features/rbac)。
* **[SSO](/learn/docs/authentication/setup/sso)** — 您的团队应使用企业凭据（Okta、Google Workspace 等）登录内部文档或 wiki。
* **[JWT](/learn/docs/authentication/setup/jwt)** — 您希望与现有登录系统集成并自己控制整个身份验证流程。支持[基于角色的访问控制](/learn/docs/authentication/features/rbac)和 [API 密钥注入](/learn/docs/authentication/features/api-key-injection)。
* **[OAuth](/learn/docs/authentication/setup/oauth)** — 您希望与现有登录系统集成，但让 Fern 通过您的 OAuth 提供商管理身份验证流程。支持[基于角色的访问控制](/learn/docs/authentication/features/rbac)和 [API 密钥注入](/learn/docs/authentication/features/api-key-injection)。

JWT 和 OAuth 具有相同的功能——区别在于谁管理身份验证流程。两者都可以用于仅登录控制，或与 [RBAC](/learn/docs/authentication/features/rbac) 和 [API 密钥注入](/learn/docs/authentication/features/api-key-injection)结合使用，实现精细的访问控制和预填充的 API 密钥。

## 身份验证的工作原理

JWT、OAuth 和 SSO 都由名为 `fern_token` 的[浏览器 cookie](/learn/docs/security/overview) 支持，它告诉 Fern 用户是谁以及他们可以访问什么。该令牌可以携带用于 [RBAC](/learn/docs/authentication/features/rbac) 的用户角色、用于 [API 浏览器](/learn/docs/api-references/api-explorer)的 API 密钥，或者只是验证用户已登录。

[密码保护](/learn/docs/authentication/setup/password-protection)的工作方式不同——它使用共享密码而不是每用户令牌。