@lobehub/chat 0.124.3 → 0.125.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +8 -8
- package/README.zh-CN.md +8 -8
- package/docs/Deployment/Authentication.md +72 -0
- package/docs/Deployment/Authentication.zh-CN.md +72 -0
- package/docs/Deployment/Environment-Variable.md +50 -0
- package/docs/Deployment/Environment-Variable.zh-CN.md +50 -0
- package/docs/Development/Authentication.md +85 -0
- package/docs/Development/Authentication.zh-CN.md +83 -0
- package/locales/ar/common.json +1 -0
- package/locales/ar/error.json +6 -0
- package/locales/ar/setting.json +16 -0
- package/locales/de-DE/common.json +1 -0
- package/locales/de-DE/error.json +6 -0
- package/locales/de-DE/setting.json +16 -0
- package/locales/en-US/common.json +1 -0
- package/locales/en-US/error.json +6 -0
- package/locales/en-US/setting.json +16 -0
- package/locales/es-ES/common.json +1 -0
- package/locales/es-ES/error.json +6 -0
- package/locales/es-ES/setting.json +16 -0
- package/locales/fr-FR/common.json +1 -0
- package/locales/fr-FR/error.json +6 -0
- package/locales/fr-FR/setting.json +16 -0
- package/locales/it-IT/common.json +1 -0
- package/locales/it-IT/error.json +6 -0
- package/locales/it-IT/setting.json +16 -0
- package/locales/ja-JP/common.json +1 -0
- package/locales/ja-JP/error.json +6 -0
- package/locales/ja-JP/setting.json +16 -0
- package/locales/ko-KR/common.json +1 -0
- package/locales/ko-KR/error.json +6 -0
- package/locales/ko-KR/setting.json +16 -0
- package/locales/nl-NL/common.json +1 -0
- package/locales/nl-NL/error.json +6 -0
- package/locales/nl-NL/setting.json +16 -0
- package/locales/pl-PL/common.json +1 -0
- package/locales/pl-PL/error.json +6 -0
- package/locales/pl-PL/setting.json +16 -0
- package/locales/pt-BR/common.json +1 -0
- package/locales/pt-BR/error.json +6 -0
- package/locales/pt-BR/setting.json +16 -0
- package/locales/ru-RU/common.json +1 -0
- package/locales/ru-RU/error.json +6 -0
- package/locales/ru-RU/setting.json +16 -0
- package/locales/tr-TR/common.json +1 -0
- package/locales/tr-TR/error.json +6 -0
- package/locales/tr-TR/setting.json +16 -0
- package/locales/vi-VN/common.json +1 -0
- package/locales/vi-VN/error.json +6 -0
- package/locales/vi-VN/setting.json +16 -0
- package/locales/zh-CN/common.json +1 -0
- package/locales/zh-CN/error.json +6 -0
- package/locales/zh-CN/setting.json +16 -0
- package/locales/zh-TW/common.json +1 -0
- package/locales/zh-TW/error.json +6 -0
- package/locales/zh-TW/setting.json +16 -0
- package/package.json +2 -1
- package/src/app/api/auth.ts +7 -1
- package/src/app/api/chat/[provider]/route.ts +5 -3
- package/src/app/api/chat/auth.ts +11 -3
- package/src/app/api/chat/google/route.ts +5 -3
- package/src/app/api/config/route.ts +9 -2
- package/src/app/api/oauth/[...nextauth]/route.ts +3 -0
- package/src/app/api/oauth/next-auth.ts +21 -0
- package/src/app/api/openai/createBizOpenAI/index.ts +3 -2
- package/src/app/api/plugin/gateway/route.ts +7 -4
- package/src/app/settings/common/Common.tsx +39 -1
- package/src/app/settings/common/page.tsx +2 -2
- package/src/app/settings/page.tsx +2 -2
- package/src/chains/summaryTitle.ts +1 -1
- package/src/config/server/app.ts +5 -0
- package/src/const/auth.ts +2 -0
- package/src/const/fetch.ts +5 -1
- package/src/features/ChatInput/ActionBar/Clear.tsx +6 -8
- package/src/features/Conversation/Error/InvalidAccessCode.tsx +28 -10
- package/src/features/Conversation/Error/OAuthForm.tsx +95 -0
- package/src/layout/GlobalLayout/index.tsx +10 -7
- package/src/locales/default/common.ts +1 -0
- package/src/locales/default/error.ts +6 -0
- package/src/locales/default/setting.ts +16 -0
- package/src/middleware.ts +25 -0
- package/src/store/global/slices/common/initialState.ts +0 -1
- package/src/store/global/slices/common/selectors.ts +1 -0
- package/src/types/settings/index.ts +1 -0
- package/tsconfig.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 0.125.0](https://github.com/lobehub/lobe-chat/compare/v0.124.3...v0.125.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-02-08**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: Support login & session authentication via OAuth 2.0 (Auth0).
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's improved
|
|
19
|
+
|
|
20
|
+
- **misc**: Support login & session authentication via OAuth 2.0 (Auth0), closes [#1143](https://github.com/lobehub/lobe-chat/issues/1143) ([0609690](https://github.com/lobehub/lobe-chat/commit/0609690))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.124.3](https://github.com/lobehub/lobe-chat/compare/v0.124.2...v0.124.3)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-02-07**</sup>
|
package/README.md
CHANGED
|
@@ -225,14 +225,14 @@ Our marketplace is not just a showcase platform but also a collaborative space.
|
|
|
225
225
|
|
|
226
226
|
<!-- AGENT LIST -->
|
|
227
227
|
|
|
228
|
-
| Recent Submits
|
|
229
|
-
|
|
|
230
|
-
| [CAN: Code Master](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup>
|
|
231
|
-
| [
|
|
232
|
-
| [
|
|
233
|
-
| [
|
|
234
|
-
|
|
235
|
-
> 📊 Total agents: [<kbd>**
|
|
228
|
+
| Recent Submits | Description |
|
|
229
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| [CAN: Code Master](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: Professional coding expert with years of experience and no character limit. Provides entrepreneurial services such as creative naming, slogans, user profiles, pain points, value propositions, sales channels, revenue streams, and cost structures.<br/>`coding` `communication` `questioning` |
|
|
231
|
+
| [Golang Architect](https://chat-preview.lobehub.com/market?agent=golang-architect)<br/><sup>By **[dalefengs](https://github.com/dalefengs)** on **2024-02-06**</sup> | Providing you with efficient, secure, and stable code solutions<br/>`architectural-design` `code-solutions` `technical-consultation` `golang` `code-development` |
|
|
232
|
+
| [Database Expert](https://chat-preview.lobehub.com/market?agent=dba)<br/><sup>By **[xuzhen1994](https://github.com/xuzhen1994)** on **2024-02-03**</sup> | Provides professional advice on database design paradigms, index optimization, query performance tuning, data security, backup and recovery.<br/>`database` `dba` `mysql` `clickhouse` `doris` `mongo-db` `oracle` |
|
|
233
|
+
| [Presentation Wizard](https://chat-preview.lobehub.com/market?agent=word)<br/><sup>By **[MYSeaIT](https://github.com/MYSeaIT)** on **2024-02-03**</sup> | App Presentation Maker Bot for Word: Assists in creating impressive and professional app presentations in Microsoft Word.<br/>`app-presentation` `microsoft-word` `bot` `assistance` `template` |
|
|
234
|
+
|
|
235
|
+
> 📊 Total agents: [<kbd>**151**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
236
236
|
|
|
237
237
|
<!-- AGENT LIST -->
|
|
238
238
|
|
package/README.zh-CN.md
CHANGED
|
@@ -205,14 +205,14 @@ LobeChat 的插件生态系统是其核心功能的重要扩展,它极大地
|
|
|
205
205
|
|
|
206
206
|
<!-- AGENT LIST -->
|
|
207
207
|
|
|
208
|
-
| 最近新增
|
|
209
|
-
|
|
|
210
|
-
| [CAN: 编程大师](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup>
|
|
211
|
-
| [
|
|
212
|
-
| [
|
|
213
|
-
| [
|
|
214
|
-
|
|
215
|
-
> 📊 Total agents: [<kbd>**
|
|
208
|
+
| 最近新增 | 助手说明 |
|
|
209
|
+
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
210
|
+
| [CAN: 编程大师](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: 专业编程专家,多年经验,无字符限制。提供创意命名、标语、用户画像、痛点、价值主张、销售渠道、收入流、成本结构等创业计划服务。<br/>`编程` `交流` `提问` |
|
|
211
|
+
| [Golang 架构师](https://chat-preview.lobehub.com/market?agent=golang-architect)<br/><sup>By **[dalefengs](https://github.com/dalefengs)** on **2024-02-06**</sup> | 为您提供高效、安全、稳定的代码方案<br/>`架构设计` `代码方案` `技术咨询` `golang` `代码开发` |
|
|
212
|
+
| [数据库专家](https://chat-preview.lobehub.com/market?agent=dba)<br/><sup>By **[xuzhen1994](https://github.com/xuzhen1994)** on **2024-02-03**</sup> | 提供关于数据库设计范式、索引优化、查询性能调优、数据安全、备份与恢复等方面的专业建议<br/>`数据库` `dba` `mysql` `clickhouse` `doris` `mongo-db` `oracle` |
|
|
213
|
+
| [演示向导](https://chat-preview.lobehub.com/market?agent=word)<br/><sup>By **[MYSeaIT](https://github.com/MYSeaIT)** on **2024-02-03**</sup> | Word 应用演示制作机器人:帮助在 Microsoft Word 中创建令人印象深刻和专业的应用程序演示。<br/>`应用程序演示` `微软-word` `机器人` `辅助` `模板` |
|
|
214
|
+
|
|
215
|
+
> 📊 Total agents: [<kbd>**151**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
216
216
|
|
|
217
217
|
<!-- AGENT LIST -->
|
|
218
218
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Authentication Service
|
|
2
|
+
|
|
3
|
+
LobeChat supports configuring external identity verification services for internal use within enterprises/organizations, facilitating centralized management of user authorizations. Currently, [Auth0][auth0-client-page] is supported. This article will guide you through the process of setting up the identity verification service.
|
|
4
|
+
|
|
5
|
+
### TOC
|
|
6
|
+
|
|
7
|
+
- [Creating an Auth0 Application](#creating-an-auth0-application)
|
|
8
|
+
- [Adding Users](#adding-users)
|
|
9
|
+
- [Configuring Environment Variables](#configuring-environment-variables)
|
|
10
|
+
- [Advanced - Connecting to an Existing Single Sign-On Service](#advanced---connecting-to-an-existing-single-sign-on-service)
|
|
11
|
+
- [Advanced - Configuring Social Login](#advanced---configuring-social-login)
|
|
12
|
+
|
|
13
|
+
## Creating an Auth0 Application
|
|
14
|
+
|
|
15
|
+
To begin, register and log in to [Auth0][auth0-client-page]. Then, navigate to the **_Applications_** section in the left sidebar to access the application management interface. Click on **_Create Application_** in the top right corner to initiate the application creation process.
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
Next, fill in the desired application name to be displayed to organization users. You can choose any application type, then click on **_Create_**.
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
Once the application is successfully created, click on the respective application to access its details page. Switch to the **_Settings_** tab to view the corresponding configuration information.
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## Adding Users
|
|
28
|
+
|
|
29
|
+
Navigate to the **_Users Management_** section in the left sidebar to access the user management interface. You can create new users for your organization to log in to LobeChat.
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
## Configuring Environment Variables
|
|
34
|
+
|
|
35
|
+
When deploying LobeChat, you need to configure the following environment variables:
|
|
36
|
+
|
|
37
|
+
| Environment Variable | Required | Description | Default Value | Example |
|
|
38
|
+
| --------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------- | ------------------------------------------------------------------ |
|
|
39
|
+
| `ENABLE_OAUTH_SSO` | Yes | Enable single sign-on (SSO) for LobeChat. Set this value to `1` to enable single sign-on. | - | `1` |
|
|
40
|
+
| `NEXTAUTH_SECRET` | Yes | The key used to encrypt the session token in Auth.js. You can generate a key using the following command: `openssl rand -base64 32` | - | `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=` |
|
|
41
|
+
| `AUTH0_CLIENT_ID` | Yes | Client ID of the Auth0 application | - | `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P` |
|
|
42
|
+
| `AUTH0_CLIENT_SECRET` | Yes | Client Secret of the Auth0 application | - | `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm` |
|
|
43
|
+
| `AUTH0_ISSUER` | Yes | Domain of the Auth0 application | - | `https://example.auth0.com` |
|
|
44
|
+
| `ACCESS_CODE` | Yes | Add a password to access this service. You can set a long random password to "disable" accessed by the code | - | `awCT74` or `e3@09!` or `code1,code2,code3` |
|
|
45
|
+
|
|
46
|
+
> \[!NOTE]
|
|
47
|
+
>
|
|
48
|
+
> After successful deployment, users will be able to authenticate and use LobeChat using the users configured in Auth0.
|
|
49
|
+
|
|
50
|
+
## Advanced - Connecting to an Existing Single Sign-On Service
|
|
51
|
+
|
|
52
|
+
If your enterprise or organization already has an existing unified identity verification infrastructure, you can connect to an existing single sign-on service in **_Applications -> SSO Integrations_**.
|
|
53
|
+
|
|
54
|
+
Auth0 supports single sign-on services such as Azure Active Directory, Slack, Google Workspace, Office 365, and Zoom. For a detailed list of supported services, refer to [this page][auth0-sso-integrations].
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
## Advanced - Configuring Social Login
|
|
59
|
+
|
|
60
|
+
If your enterprise or organization needs to support external personnel login, you can configure social login services in **_Authentication -> Social_**.
|
|
61
|
+
|
|
62
|
+

|
|
63
|
+
|
|
64
|
+
> \[!NOTE]
|
|
65
|
+
>
|
|
66
|
+
> Configuring social login services will allow anyone to authenticate by default, which may lead to abuse of LobeChat by external personnel. If you need to restrict login personnel, be sure to configure a blocking policy.
|
|
67
|
+
>
|
|
68
|
+
> After enabling social login options, refer to [this article][auth0-login-actions-manual] to create an Action to set the deny/allow list.
|
|
69
|
+
|
|
70
|
+
[auth0-client-page]: https://manage.auth0.com/dashboard
|
|
71
|
+
[auth0-login-actions-manual]: https://auth0.com/blog/permit-or-deny-login-requests-using-auth0-actions/
|
|
72
|
+
[auth0-sso-integrations]: https://marketplace.auth0.com/features/sso-integrations
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# 身份验证服务
|
|
2
|
+
|
|
3
|
+
LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权,目前支持 [Auth0][auth0-client-page] 本文将介绍如何配置身份验证服务。
|
|
4
|
+
|
|
5
|
+
### TOC
|
|
6
|
+
|
|
7
|
+
- [创建 Auth0 应用](#创建-auth0-应用)
|
|
8
|
+
- [新增用户](#新增用户)
|
|
9
|
+
- [配置环境变量](#配置环境变量)
|
|
10
|
+
- [进阶 - 连接现有的单点登录服务](#进阶---连接现有的单点登录服务)
|
|
11
|
+
- [进阶 - 配置社交登录](#进阶---配置社交登录)
|
|
12
|
+
|
|
13
|
+
## 创建 Auth0 应用
|
|
14
|
+
|
|
15
|
+
注册并登录 [Auth0][auth0-client-page],点击左侧导航栏的「Applications」,切换到应用管理界面,点击右上角「Create Application」以创建应用。
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
填写你想向组织用户显示的应用名称,可选择任意应用类型,点击「Create」。
|
|
20
|
+
|
|
21
|
+

|
|
22
|
+
|
|
23
|
+
创建成功后,点击相应的应用,进入应用详情页,切换到「Settings」标签页,就可以看到相应的配置信息
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
## 新增用户
|
|
28
|
+
|
|
29
|
+
点击左侧导航栏的「Users Management」,进入用户管理界面,可以为你的组织新建用户,用以登录 LobeChat
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
## 配置环境变量
|
|
34
|
+
|
|
35
|
+
在部署 LobeChat 时,你需要配置以下环境变量:
|
|
36
|
+
|
|
37
|
+
| 环境变量 | 类型 | 描述 | 默认值 | 示例 |
|
|
38
|
+
| --------------------- | ---- | --------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------ |
|
|
39
|
+
| `ENABLE_OAUTH_SSO` | 必选 | 为 LobeChat 启用单点登录 (SSO)。设置为 `1` 以启用单点登录。 | - | `1` |
|
|
40
|
+
| `NEXTAUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` | - | `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=` |
|
|
41
|
+
| `AUTH0_CLIENT_ID` | 必选 | Auth0 应用程序的 Client ID | - | `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P` |
|
|
42
|
+
| `AUTH0_CLIENT_SECRET` | 必选 | Auth0 应用程序的 Client Secret | - | `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm` |
|
|
43
|
+
| `AUTH0_ISSUER` | 必选 | Auth0 应用程序的 Domain | - | `https://example.auth0.com` |
|
|
44
|
+
| `ACCESS_CODE` | 必选 | 添加访问此服务的密码,你可以设置一个足够长的随机密码以 “禁用” 访问码授权 | - | `awCT74` 或 `e3@09!` or `code1,code2,code3` |
|
|
45
|
+
|
|
46
|
+
> \[!NOTE]
|
|
47
|
+
>
|
|
48
|
+
> 部署成功后,用户将可以使用 Auth0 中配置的用户通过身份认证并使用 LobeChat。
|
|
49
|
+
|
|
50
|
+
## 进阶 - 连接现有的单点登录服务
|
|
51
|
+
|
|
52
|
+
如果你的企业或组织已有现有的统一身份认证设施,可在 Applications -> SSO Integrations 中,连接现有的单点登录服务。
|
|
53
|
+
|
|
54
|
+
Auth0 支持 Azure Active Directory, Slack, Google Workspace, Office 365, Zoom 等单点登录服务,详细支持列表可参考 [这里][auth0-sso-integrations]
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
|
|
58
|
+
## 进阶 - 配置社交登录
|
|
59
|
+
|
|
60
|
+
如果你的企业或组织需要支持外部人员登录,可以在 Authentication -> Social 中,配置社交登录服务。
|
|
61
|
+
|
|
62
|
+

|
|
63
|
+
|
|
64
|
+
> \[!NOTE]
|
|
65
|
+
>
|
|
66
|
+
> 配置社交登录服务默认会允许所有人通过认证,这可能会导致 LobeChat 被外部人员滥用。如果你需要限制登录人员,务必配置阻止策略
|
|
67
|
+
>
|
|
68
|
+
> 请在打开社交登录选项后,参考 [这篇文章][auth0-login-actions-manual] 创建 Action 来设置阻止 / 允许 列表
|
|
69
|
+
|
|
70
|
+
[auth0-client-page]: https://manage.auth0.com/dashboard
|
|
71
|
+
[auth0-login-actions-manual]: https://auth0.com/blog/permit-or-deny-login-requests-using-auth0-actions/
|
|
72
|
+
[auth0-sso-integrations]: https://marketplace.auth0.com/features/sso-integrations
|
|
@@ -6,6 +6,10 @@ LobeChat provides additional configuration options during deployment, which can
|
|
|
6
6
|
|
|
7
7
|
- [General Variables](#general-variables)
|
|
8
8
|
- [`ACCESS_CODE`](#access_code)
|
|
9
|
+
- [`ENABLE_OAUTH_SSO`](#enable_oauth_sso)
|
|
10
|
+
- [Authentication Service Providers](#authentication-service-providers)
|
|
11
|
+
- [Common Settings](#common-settings)
|
|
12
|
+
- [Auth0](#auth0)
|
|
9
13
|
- [Model Service Providers](#model-service-providers)
|
|
10
14
|
- [OpenAI](#openai)
|
|
11
15
|
- [Azure OpenAI](#azure-openai)
|
|
@@ -31,6 +35,51 @@ LobeChat provides additional configuration options during deployment, which can
|
|
|
31
35
|
- Default: `-`
|
|
32
36
|
- Example: `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3`
|
|
33
37
|
|
|
38
|
+
### `ENABLE_OAUTH_SSO`
|
|
39
|
+
|
|
40
|
+
- Type: Optional
|
|
41
|
+
- Description: Enable OAuth single sign-on (SSO) for LobeChat. Set to `1` to enable OAuth SSO. See [Authentication Service Providers](#authentication-service-providers) for more details.
|
|
42
|
+
- Default: `-`
|
|
43
|
+
- Example: `1` or `0`
|
|
44
|
+
|
|
45
|
+
## Authentication Service Providers
|
|
46
|
+
|
|
47
|
+
### Common Settings
|
|
48
|
+
|
|
49
|
+
#### `NEXTAUTH_SECRET`
|
|
50
|
+
|
|
51
|
+
- Type: Required
|
|
52
|
+
- Description: The secret key used to encrypt the Auth.js session token. You can generate a secret key using the following command: `openssl rand -base64 32`
|
|
53
|
+
- Default: `-`
|
|
54
|
+
- Example: `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=`
|
|
55
|
+
|
|
56
|
+
### Auth0
|
|
57
|
+
|
|
58
|
+
> !\[NOTE]
|
|
59
|
+
>
|
|
60
|
+
> We only support the Auth0 authentication service provider at the moment. If you need to use other authentication service providers, you can submit a feature request or pull request.
|
|
61
|
+
|
|
62
|
+
#### `AUTH0_CLIENT_ID`
|
|
63
|
+
|
|
64
|
+
- Type: Required
|
|
65
|
+
- Description: The Client ID of the Auth0 application, you can go [here][auth0-client-page] and navigate to the application settings to view
|
|
66
|
+
- Default: `-`
|
|
67
|
+
- Example: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
|
|
68
|
+
|
|
69
|
+
#### `AUTH0_CLIENT_SECRET`
|
|
70
|
+
|
|
71
|
+
- Type: Required
|
|
72
|
+
- Description: The Client Secret of the Auth0 application
|
|
73
|
+
- Default: `-`
|
|
74
|
+
- Example: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
|
|
75
|
+
|
|
76
|
+
#### `AUTH0_ISSUER`
|
|
77
|
+
|
|
78
|
+
- Type: Required
|
|
79
|
+
- Description: The issuer/domain of the Auth0 application
|
|
80
|
+
- Default: `-`
|
|
81
|
+
- Example: `https://example.auth0.com`
|
|
82
|
+
|
|
34
83
|
## Model Service Providers
|
|
35
84
|
|
|
36
85
|
### OpenAI
|
|
@@ -237,6 +286,7 @@ The above example adds `search-engine` plugin settings, and sets the `SERPAPI_AP
|
|
|
237
286
|
- Default: -
|
|
238
287
|
- Example: `1`
|
|
239
288
|
|
|
289
|
+
[auth0-client-page]: https://manage.auth0.com/dashboard
|
|
240
290
|
[azure-api-verion-url]: https://docs.microsoft.com/zh-cn/azure/developer/javascript/api-reference/es-modules/azure-sdk/ai-translation/translationconfiguration?view=azure-node-latest#api-version
|
|
241
291
|
[openai-api-page]: https://platform.openai.com/account/api-keys
|
|
242
292
|
[posthog-analytics-url]: https://posthog.com
|
|
@@ -6,6 +6,10 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
6
6
|
|
|
7
7
|
- [通用变量](#通用变量)
|
|
8
8
|
- [`ACCESS_CODE`](#access_code)
|
|
9
|
+
- [`ENABLE_OAUTH_SSO`](#enable_oauth_sso)
|
|
10
|
+
- [身份验证服务](#身份验证服务)
|
|
11
|
+
- [通用设置](#通用设置)
|
|
12
|
+
- [Auth0](#auth0)
|
|
9
13
|
- [模型服务商](#模型服务商)
|
|
10
14
|
- [OpenAI](#openai)
|
|
11
15
|
- [Azure OpenAI](#azure-openai)
|
|
@@ -31,6 +35,51 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
31
35
|
- 默认值:-
|
|
32
36
|
- 示例:`awCTe)re_r74` or `rtrt_ewee3@09!`
|
|
33
37
|
|
|
38
|
+
### `ENABLE_OAUTH_SSO`
|
|
39
|
+
|
|
40
|
+
- 类型:可选
|
|
41
|
+
- 描述:为 LobeChat 启用单点登录 (SSO)。设置为 `1` 以启用单点登录。有关详细信息,请参阅[身份验证服务](#身份验证服务)。
|
|
42
|
+
- 默认值: `-`
|
|
43
|
+
- 示例: `1` 或 `0`
|
|
44
|
+
|
|
45
|
+
## 身份验证服务
|
|
46
|
+
|
|
47
|
+
### 通用设置
|
|
48
|
+
|
|
49
|
+
#### `NEXTAUTH_SECRET`
|
|
50
|
+
|
|
51
|
+
- 类型:必须
|
|
52
|
+
- 描述:用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32`.
|
|
53
|
+
- 默认值: `-`
|
|
54
|
+
- 示例: `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=`
|
|
55
|
+
|
|
56
|
+
### Auth0
|
|
57
|
+
|
|
58
|
+
> !\[NOTE] 注意事项:
|
|
59
|
+
>
|
|
60
|
+
> 目前我们只支持 Auth0 身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交功能请求或 Pull Request。
|
|
61
|
+
|
|
62
|
+
#### `AUTH0_CLIENT_ID`
|
|
63
|
+
|
|
64
|
+
- 类型:必须
|
|
65
|
+
- 描述: Auth0 应用程序的 Client ID,您可以访问[这里][auth0-client-page]并导航至应用程序设置来查看
|
|
66
|
+
- 默认值: `-`
|
|
67
|
+
- 示例: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
|
|
68
|
+
|
|
69
|
+
#### `AUTH0_CLIENT_SECRET`
|
|
70
|
+
|
|
71
|
+
- 类型:必须
|
|
72
|
+
- 描述: Auth0 应用程序的 Client Secret
|
|
73
|
+
- 默认值: `-`
|
|
74
|
+
- 示例: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
|
|
75
|
+
|
|
76
|
+
#### `AUTH0_ISSUER`
|
|
77
|
+
|
|
78
|
+
- 类型:必须
|
|
79
|
+
- 描述: Auth0 应用程序的签发人 / 域
|
|
80
|
+
- 默认值: `-`
|
|
81
|
+
- 示例: `https://example.auth0.com`
|
|
82
|
+
|
|
34
83
|
## 模型服务商
|
|
35
84
|
|
|
36
85
|
### OpenAI
|
|
@@ -233,6 +282,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
233
282
|
- 默认值: `-`
|
|
234
283
|
- 示例:`1`
|
|
235
284
|
|
|
285
|
+
[auth0-client-page]: https://manage.auth0.com/dashboard
|
|
236
286
|
[azure-api-verion-url]: https://docs.microsoft.com/zh-cn/azure/developer/javascript/api-reference/es-modules/azure-sdk/ai-translation/translationconfiguration?view=azure-node-latest#api-version
|
|
237
287
|
[openai-api-page]: https://platform.openai.com/account/api-keys
|
|
238
288
|
[posthog-analytics-url]: https://posthog.com
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# New Authentication Provider Guide
|
|
2
|
+
|
|
3
|
+
LobeChat uses [Auth.js v5](https://authjs.dev/) as the external authentication service. Auth.js is an open-source authentication library that provides a simple way to implement authentication and authorization features. This document will introduce how to use Auth.js to implement a new authentication provider.
|
|
4
|
+
|
|
5
|
+
### TOC
|
|
6
|
+
|
|
7
|
+
- [Add New Authentication Provider](#add-new-authentication-provider)
|
|
8
|
+
- [Pre-requisites: Check the Official Provider List](#pre-requisites-check-the-official-provider-list)
|
|
9
|
+
- [Step 1: Add Authenticator Core Code](#step-1-add-authenticator-core-code)
|
|
10
|
+
- [Step 2: Update Server Configuration Code](#step-2-update-server-configuration-code)
|
|
11
|
+
- [Step 3: Change Frontend Pages](#step-3-change-frontend-pages)
|
|
12
|
+
- [Step 4: Configure the Environment Variables](#step-4-configure-the-environment-variables)
|
|
13
|
+
|
|
14
|
+
## Add New Authentication Provider
|
|
15
|
+
|
|
16
|
+
To add a new authentication provider in LobeChat (for example, adding Okta), you need to follow the steps below:
|
|
17
|
+
|
|
18
|
+
### Pre-requisites: Check the Official Provider List
|
|
19
|
+
|
|
20
|
+
First, you need to check the [Auth.js Provider List](https://authjs.dev/reference/core/providers) to see if your provider is already supported. If yes, you can directly use the SDK provided by Auth.js to implement the authentication feature.
|
|
21
|
+
|
|
22
|
+
Next, I will use [Okta](https://authjs.dev/reference/core/providers/okta) as an example to introduce how to add a new authentication provider.
|
|
23
|
+
|
|
24
|
+
### Step 1: Add Authenticator Core Code
|
|
25
|
+
|
|
26
|
+
Open the `src/app/api/oauth/next-auth.ts` file and import `next-auth/providers/okta`.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { NextAuth } from 'next-auth';
|
|
30
|
+
import Auth0 from 'next-auth/providers/auth0';
|
|
31
|
+
import Okta from 'next-auth/providers/okta';
|
|
32
|
+
|
|
33
|
+
// Import Okta provider
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Add the predefined server configuration.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// Import server configuration
|
|
40
|
+
const { OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, OKTA_ISSUER } = getServerConfig();
|
|
41
|
+
|
|
42
|
+
const nextAuth = NextAuth({
|
|
43
|
+
providers: [
|
|
44
|
+
// ... Other providers
|
|
45
|
+
|
|
46
|
+
Okta({
|
|
47
|
+
clientId: OKTA_CLIENT_ID,
|
|
48
|
+
clientSecret: OKTA_CLIENT_SECRET,
|
|
49
|
+
issuer: OKTA_ISSUER,
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Step 2: Update Server Configuration Code
|
|
56
|
+
|
|
57
|
+
Open the `src/config/server/app.ts` file and add Okta-related environment variables in the `getAppConfig` function.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
export const getAppConfig = () => {
|
|
61
|
+
// ... Other code
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
// ... Other environment variables
|
|
65
|
+
|
|
66
|
+
OKTA_CLIENT_ID: process.env.OKTA_CLIENT_ID || '',
|
|
67
|
+
OKTA_CLIENT_SECRET: process.env.OKTA_CLIENT_SECRET || '',
|
|
68
|
+
OKTA_ISSUER: process.env.OKTA_ISSUER || '',
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Step 3: Change Frontend Pages
|
|
74
|
+
|
|
75
|
+
Modify the `signIn` function parameter in `src/Features/Conversation/Error/OAuthForm.tsx` and \`src/app/settings/common/Common.tsx
|
|
76
|
+
|
|
77
|
+
The default is `auth0`, which you can change to `okta` to switch to the Okta provider, or remove this parameter to support all added authentication services
|
|
78
|
+
|
|
79
|
+
This value is the id of the Auth.js provider, and you can read the source code of the corresponding `next-auth/providers` module to read the default ID.
|
|
80
|
+
|
|
81
|
+
### Step 4: Configure the Environment Variables
|
|
82
|
+
|
|
83
|
+
Add `OKTA_CLIENT_ID`、`OKTA_CLIENT_SECRET`、`OKTA_ISSUER` environment variables when you deploy.
|
|
84
|
+
|
|
85
|
+
Now, you can use Okta as your provider to implement the authentication feature in LobeChat.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# 新身份验证方式开发指南
|
|
2
|
+
|
|
3
|
+
LobeChat 使用 [Auth.js v5](https://authjs.dev/) 作为外部身份验证服务。Auth.js 是一个开源的身份验证库,它提供了一种简单的方式来实现身份验证和授权功能。本文档将介绍如何使用 Auth.js 来实现新的身份验证方式。
|
|
4
|
+
|
|
5
|
+
### TOC
|
|
6
|
+
|
|
7
|
+
- [添加新的身份验证提供者](#添加新的身份验证提供者)
|
|
8
|
+
- [准备工作:查阅官方的提供者列表](#准备工作查阅官方的提供者列表)
|
|
9
|
+
- [步骤 1: 新增关键代码](#步骤-1-新增关键代码)
|
|
10
|
+
- [步骤 2: 更新服务端配置代码](#步骤-2-更新服务端配置代码)
|
|
11
|
+
- [步骤 3: 修改前端页面](#步骤-3-修改前端页面)
|
|
12
|
+
- [步骤 4: 配置环境变量](#步骤-4-配置环境变量)
|
|
13
|
+
|
|
14
|
+
## 添加新的身份验证提供者
|
|
15
|
+
|
|
16
|
+
为了在 LobeChat 中添加新的身份验证提供者(例如添加 Okta),你需要完成以下步骤:
|
|
17
|
+
|
|
18
|
+
### 准备工作:查阅官方的提供者列表
|
|
19
|
+
|
|
20
|
+
首先,你需要查阅 [Auth.js 提供者列表](https://authjs.dev/reference/core/providers) 来了解是否你的提供者已经被支持。如果你的提供者已经被支持,你可以直接使用 Auth.js 提供的 SDK 来实现身份验证功能。
|
|
21
|
+
|
|
22
|
+
接下来我会以 [Okta](https://authjs.dev/reference/core/providers/okta) 为例来介绍如何添加新的身份验证提供者
|
|
23
|
+
|
|
24
|
+
### 步骤 1: 新增关键代码
|
|
25
|
+
|
|
26
|
+
打开 `src/app/api/oauth/next-auth.ts` 文件,引入 `next-auth/providers/okta`
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { NextAuth } from 'next-auth';
|
|
30
|
+
import Auth0 from 'next-auth/providers/auth0';
|
|
31
|
+
import Okta from 'next-auth/providers/okta';
|
|
32
|
+
|
|
33
|
+
// 引入 Okta 提供者
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
新增预定义的服务端配置
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// 导入服务器配置
|
|
40
|
+
const { OKTA_CLIENT_ID, OKTA_CLIENT_SECRET, OKTA_ISSUER } = getServerConfig();
|
|
41
|
+
|
|
42
|
+
const nextAuth = NextAuth({
|
|
43
|
+
providers: [
|
|
44
|
+
// ... 其他提供者
|
|
45
|
+
|
|
46
|
+
Okta({
|
|
47
|
+
clientId: OKTA_CLIENT_ID,
|
|
48
|
+
clientSecret: OKTA_CLIENT_SECRET,
|
|
49
|
+
issuer: OKTA_ISSUER,
|
|
50
|
+
}),
|
|
51
|
+
],
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 步骤 2: 更新服务端配置代码
|
|
56
|
+
|
|
57
|
+
打开 `src/config/server/app.ts` 文件,在 `getAppConfig` 函数中新增 Okta 相关的环境变量
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
export const getAppConfig = () => {
|
|
61
|
+
// ... 其他代码
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
// ... 其他环境变量
|
|
65
|
+
|
|
66
|
+
OKTA_CLIENT_ID: process.env.OKTA_CLIENT_ID || '',
|
|
67
|
+
OKTA_CLIENT_SECRET: process.env.OKTA_CLIENT_SECRET || '',
|
|
68
|
+
OKTA_ISSUER: process.env.OKTA_ISSUER || '',
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 步骤 3: 修改前端页面
|
|
74
|
+
|
|
75
|
+
修改在 `src/features/Conversation/Error/OAuthForm.tsx` 及 `src/app/settings/common/Common.tsx` 中的 `signIn` 函数参数
|
|
76
|
+
|
|
77
|
+
默认为 `auth0`,你可以将其修改为 `okta` 以切换到 Okta 提供者,或删除该参数以支持所有已添加的身份验证服务
|
|
78
|
+
|
|
79
|
+
该值为 Auth.js 提供者 的 id,你可以阅读相应的 `next-auth/providers` 模块源码以读取默认 ID
|
|
80
|
+
|
|
81
|
+
### 步骤 4: 配置环境变量
|
|
82
|
+
|
|
83
|
+
在部署时新增 Okta 相关的环境变量 `OKTA_CLIENT_ID`、`OKTA_CLIENT_SECRET`、`OKTA_ISSUER`,并填入相应的值,即可使用
|
package/locales/ar/common.json
CHANGED
package/locales/ar/error.json
CHANGED
|
@@ -94,6 +94,12 @@
|
|
|
94
94
|
},
|
|
95
95
|
"closeMessage": "إغلاق الرسالة",
|
|
96
96
|
"confirm": "تأكيد وإعادة المحاولة",
|
|
97
|
+
"oauth": {
|
|
98
|
+
"description": "فتح المسؤول توثيق تسجيل الدخول الموحد، انقر فوق الزر أدناه لتسجيل الدخول وفتح التطبيق",
|
|
99
|
+
"success": "تم تسجيل الدخول بنجاح",
|
|
100
|
+
"title": "تسجيل الدخول إلى الحساب",
|
|
101
|
+
"welcome": "مرحبا بك!"
|
|
102
|
+
},
|
|
97
103
|
"password": {
|
|
98
104
|
"description": "قام المسؤول بتشفير التطبيق، قم بإدخال كلمة مرور التطبيق لفتح التطبيق. يتعين إدخال كلمة المرور مرة واحدة فقط",
|
|
99
105
|
"placeholder": "الرجاء إدخال كلمة المرور",
|
package/locales/ar/setting.json
CHANGED
|
@@ -263,6 +263,22 @@
|
|
|
263
263
|
"placeholder": "الرجاء إدخال كلمة المرور",
|
|
264
264
|
"title": "كلمة المرور"
|
|
265
265
|
},
|
|
266
|
+
"oauth": {
|
|
267
|
+
"info": {
|
|
268
|
+
"desc": "تم تسجيل الدخول",
|
|
269
|
+
"title": "معلومات الحساب"
|
|
270
|
+
},
|
|
271
|
+
"signin": {
|
|
272
|
+
"action": "تسجيل الدخول",
|
|
273
|
+
"desc": "قم بتسجيل الدخول باستخدام SSO لفتح التطبيق",
|
|
274
|
+
"title": "تسجيل الدخول إلى الحساب"
|
|
275
|
+
},
|
|
276
|
+
"signout": {
|
|
277
|
+
"action": "تسجيل الخروج",
|
|
278
|
+
"confirm": "هل ترغب في تأكيد الخروج؟",
|
|
279
|
+
"success": "تم تسجيل الخروج بنجاح"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
266
282
|
"title": "إعدادات النظام"
|
|
267
283
|
},
|
|
268
284
|
"settingTTS": {
|
package/locales/de-DE/error.json
CHANGED
|
@@ -94,6 +94,12 @@
|
|
|
94
94
|
},
|
|
95
95
|
"closeMessage": "Hinweis schließen",
|
|
96
96
|
"confirm": "Bestätigen und erneut versuchen",
|
|
97
|
+
"oauth": {
|
|
98
|
+
"description": "Der Administrator hat die einheitliche Anmeldeauthentifizierung aktiviert. Klicken Sie unten auf die Schaltfläche, um sich anzumelden und die App zu entsperren.",
|
|
99
|
+
"success": "Anmeldung erfolgreich",
|
|
100
|
+
"title": "Anmelden",
|
|
101
|
+
"welcome": "Willkommen!"
|
|
102
|
+
},
|
|
97
103
|
"password": {
|
|
98
104
|
"description": "Der Administrator hat die App-Verschlüsselung aktiviert. Gib das App-Passwort ein, um die App zu entsperren. Das Passwort muss nur einmal eingegeben werden.",
|
|
99
105
|
"placeholder": "Passwort eingeben",
|
|
@@ -263,6 +263,22 @@
|
|
|
263
263
|
"placeholder": "Bitte geben Sie das Zugangspasswort ein",
|
|
264
264
|
"title": "Zugangspasswort"
|
|
265
265
|
},
|
|
266
|
+
"oauth": {
|
|
267
|
+
"info": {
|
|
268
|
+
"desc": "Angemeldet",
|
|
269
|
+
"title": "Kontoinformationen"
|
|
270
|
+
},
|
|
271
|
+
"signin": {
|
|
272
|
+
"action": "Anmelden",
|
|
273
|
+
"desc": "Mit SSO anmelden, um die Anwendung freizuschalten",
|
|
274
|
+
"title": "Konto anmelden"
|
|
275
|
+
},
|
|
276
|
+
"signout": {
|
|
277
|
+
"action": "Abmelden",
|
|
278
|
+
"confirm": "Abmelden bestätigen?",
|
|
279
|
+
"success": "Abmeldung erfolgreich"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
266
282
|
"title": "Systemeinstellungen"
|
|
267
283
|
},
|
|
268
284
|
"settingTTS": {
|