> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/pei-zhi/overleaf-toolkit/authentication.md).

# 身份验证

此功能由 [yu-i-i/overleaf-cep](https://github.com/yu-i-i/overleaf-cep). 支持 3 种认证方式。配置完成后，你可以使用以下选项登录，如下图所示。

<figure><img src="/files/cb7b7cf014c700357fff75dce0c038f3edaea709" alt=""><figcaption></figcaption></figure>

我们强烈建议你使用 OIDC，因为这是最通用的方法。

{% columns %}
{% column width="50%" %}
{% content-ref url="/pages/ab3a72bb3721d73d2cc1f3c7aa5a6a28c9df8746" %}
[OIDC 身份验证](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/authentication/oidc-authentication.md)
{% endcontent-ref %}

{% content-ref url="/pages/2a3ca57fd09b334ba6e3f686d20bcc9056af36fe" %}
[LDAP 身份验证](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/authentication/ldap-authentication.md)
{% endcontent-ref %}
{% endcolumn %}

{% column width="50%" %}
{% content-ref url="/pages/b96e9eddbac2cba2b6de360f20d785469fe47467" %}
[SAML 身份验证](/on-premises/zh-cn/pei-zhi/overleaf-toolkit/authentication/saml-authentication.md)
{% endcontent-ref %}
{% endcolumn %}
{% endcolumns %}

### 全局配置

环境变量 `EXTERNAL_AUTH` 是启用特定认证模块所必需的。此环境变量指定启用了哪些外部认证方式。可用选项如下（小写）：

* saml
* ldap
* oidc

### SSO 建议

我在 overleaf 上测试了 saml、ldap、oauth。saml 和 oauth 在 overleaf 中都运行良好，但 ldap 则取决于情况。它无法很好地用于 <https://docs.goauthentik.io/>，但它在 openLDAP 中运行良好（<https://github.com/rroemhild/docker-test-openldap>).

{% hint style="info" %}
我们需要更新 passport-ldapauth，最近我正在尝试用 <https://goauthentik.io/> 测试 overleaf ldap，但失败了。将“passport-ldapauth”更新到 3.0.0 后，一切都运行良好。

```
"passport-ldapauth": "^3.0.0",
```

最初的是 2.x.x，那已经是 6 年前的版本了。
{% endhint %}

我不确定原因是什么，因为我们都依赖外部包来进行 LDAP（以及 saml、oauth）认证。如果不起作用，对 overleaf server pro 来说情况也可能一样，因为我们只是把所有环境变量传给内部包；如果有一些 bug，我们目前也无从得知。

**所以我强烈建议我们的用户搭建开发环境，并使用全部源代码来测试 SSO**，它可在 [Setup Develop Environment (Local)](/dev/environment/setup-develop-environment-local.md)获取。在开发环境中，你可以在终端中看到所有日志，这使调试更加方便。

\ <br>


---

# 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 dynamically by asking a question.

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

```
GET https://ayakaleaf-pro.ayaka.space/on-premises/zh-cn/pei-zhi/overleaf-toolkit/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
