@lobehub/chat 0.124.3 → 0.126.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.
Files changed (90) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +8 -8
  3. package/README.zh-CN.md +8 -8
  4. package/docs/Deployment/Authentication.md +72 -0
  5. package/docs/Deployment/Authentication.zh-CN.md +72 -0
  6. package/docs/Deployment/Environment-Variable.md +75 -0
  7. package/docs/Deployment/Environment-Variable.zh-CN.md +76 -0
  8. package/docs/Development/Authentication.md +85 -0
  9. package/docs/Development/Authentication.zh-CN.md +83 -0
  10. package/locales/ar/common.json +1 -0
  11. package/locales/ar/error.json +6 -0
  12. package/locales/ar/setting.json +16 -0
  13. package/locales/de-DE/common.json +1 -0
  14. package/locales/de-DE/error.json +6 -0
  15. package/locales/de-DE/setting.json +16 -0
  16. package/locales/en-US/common.json +1 -0
  17. package/locales/en-US/error.json +6 -0
  18. package/locales/en-US/setting.json +16 -0
  19. package/locales/es-ES/common.json +1 -0
  20. package/locales/es-ES/error.json +6 -0
  21. package/locales/es-ES/setting.json +16 -0
  22. package/locales/fr-FR/common.json +1 -0
  23. package/locales/fr-FR/error.json +6 -0
  24. package/locales/fr-FR/setting.json +16 -0
  25. package/locales/it-IT/common.json +1 -0
  26. package/locales/it-IT/error.json +6 -0
  27. package/locales/it-IT/setting.json +16 -0
  28. package/locales/ja-JP/common.json +1 -0
  29. package/locales/ja-JP/error.json +6 -0
  30. package/locales/ja-JP/setting.json +16 -0
  31. package/locales/ko-KR/common.json +1 -0
  32. package/locales/ko-KR/error.json +6 -0
  33. package/locales/ko-KR/setting.json +16 -0
  34. package/locales/nl-NL/common.json +1 -0
  35. package/locales/nl-NL/error.json +6 -0
  36. package/locales/nl-NL/setting.json +16 -0
  37. package/locales/pl-PL/common.json +1 -0
  38. package/locales/pl-PL/error.json +6 -0
  39. package/locales/pl-PL/setting.json +16 -0
  40. package/locales/pt-BR/common.json +1 -0
  41. package/locales/pt-BR/error.json +6 -0
  42. package/locales/pt-BR/setting.json +16 -0
  43. package/locales/ru-RU/common.json +1 -0
  44. package/locales/ru-RU/error.json +6 -0
  45. package/locales/ru-RU/setting.json +16 -0
  46. package/locales/tr-TR/common.json +1 -0
  47. package/locales/tr-TR/error.json +6 -0
  48. package/locales/tr-TR/setting.json +16 -0
  49. package/locales/vi-VN/common.json +1 -0
  50. package/locales/vi-VN/error.json +6 -0
  51. package/locales/vi-VN/setting.json +16 -0
  52. package/locales/zh-CN/common.json +1 -0
  53. package/locales/zh-CN/error.json +6 -0
  54. package/locales/zh-CN/setting.json +16 -0
  55. package/locales/zh-TW/common.json +1 -0
  56. package/locales/zh-TW/error.json +6 -0
  57. package/locales/zh-TW/setting.json +16 -0
  58. package/package.json +2 -1
  59. package/src/app/api/auth.ts +7 -1
  60. package/src/app/api/chat/[provider]/route.ts +5 -3
  61. package/src/app/api/chat/auth.ts +11 -3
  62. package/src/app/api/chat/google/route.ts +5 -3
  63. package/src/app/api/config/route.ts +9 -2
  64. package/src/app/api/oauth/[...nextauth]/route.ts +3 -0
  65. package/src/app/api/oauth/next-auth.ts +21 -0
  66. package/src/app/api/openai/createBizOpenAI/index.ts +3 -2
  67. package/src/app/api/plugin/gateway/route.ts +7 -4
  68. package/src/app/chat/settings/(desktop)/features/Header.tsx +1 -1
  69. package/src/app/settings/common/Common.tsx +39 -1
  70. package/src/app/settings/common/page.tsx +2 -2
  71. package/src/app/settings/page.tsx +2 -2
  72. package/src/chains/summaryTitle.ts +1 -1
  73. package/src/components/Analytics/Umami.tsx +15 -0
  74. package/src/components/Analytics/index.tsx +4 -1
  75. package/src/config/client.ts +10 -0
  76. package/src/config/server/app.ts +5 -0
  77. package/src/const/auth.ts +2 -0
  78. package/src/const/fetch.ts +5 -1
  79. package/src/features/ChatInput/ActionBar/Clear.tsx +6 -8
  80. package/src/features/Conversation/Error/InvalidAccessCode.tsx +28 -10
  81. package/src/features/Conversation/Error/OAuthForm.tsx +95 -0
  82. package/src/layout/GlobalLayout/index.tsx +10 -7
  83. package/src/locales/default/common.ts +1 -0
  84. package/src/locales/default/error.ts +6 -0
  85. package/src/locales/default/setting.ts +16 -0
  86. package/src/middleware.ts +25 -0
  87. package/src/store/global/slices/common/initialState.ts +0 -1
  88. package/src/store/global/slices/common/selectors.ts +1 -0
  89. package/src/types/settings/index.ts +1 -0
  90. package/tsconfig.json +8 -8
package/CHANGELOG.md CHANGED
@@ -2,6 +2,64 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## [Version 0.126.0](https://github.com/lobehub/lobe-chat/compare/v0.125.0...v0.126.0)
6
+
7
+ <sup>Released on **2024-02-09**</sup>
8
+
9
+ #### ✨ Features
10
+
11
+ - **misc**: Support umami analytics.
12
+
13
+ #### 🐛 Bug Fixes
14
+
15
+ - **misc**: The back button on the chat setting page can correctly return to the configured Agent chat page.
16
+
17
+ <br/>
18
+
19
+ <details>
20
+ <summary><kbd>Improvements and Fixes</kbd></summary>
21
+
22
+ #### What's improved
23
+
24
+ - **misc**: Support umami analytics, closes [#1267](https://github.com/lobehub/lobe-chat/issues/1267) ([da7beba](https://github.com/lobehub/lobe-chat/commit/da7beba))
25
+
26
+ #### What's fixed
27
+
28
+ - **misc**: The back button on the chat setting page can correctly return to the configured Agent chat page, closes [#1272](https://github.com/lobehub/lobe-chat/issues/1272) ([4cc1ad5](https://github.com/lobehub/lobe-chat/commit/4cc1ad5))
29
+
30
+ </details>
31
+
32
+ <div align="right">
33
+
34
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
35
+
36
+ </div>
37
+
38
+ ## [Version 0.125.0](https://github.com/lobehub/lobe-chat/compare/v0.124.3...v0.125.0)
39
+
40
+ <sup>Released on **2024-02-08**</sup>
41
+
42
+ #### ✨ Features
43
+
44
+ - **misc**: Support login & session authentication via OAuth 2.0 (Auth0).
45
+
46
+ <br/>
47
+
48
+ <details>
49
+ <summary><kbd>Improvements and Fixes</kbd></summary>
50
+
51
+ #### What's improved
52
+
53
+ - **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))
54
+
55
+ </details>
56
+
57
+ <div align="right">
58
+
59
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
60
+
61
+ </div>
62
+
5
63
  ### [Version 0.124.3](https://github.com/lobehub/lobe-chat/compare/v0.124.2...v0.124.3)
6
64
 
7
65
  <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 | 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
- | [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` |
232
- | [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` |
233
- | [SagePathfinder](https://chat-preview.lobehub.com/market?agent=sage-pathfinder)<br/><sup>By **[Ajasra](https://github.com/Ajasra)** on **2024-01-31**</sup> | Expert in personal growth coaching with a focus on stoicism, deep reflection, and strategic questioning.<br/>`personal-growth` `coaching` `reflection` `goal-setting` `well-being` |
234
-
235
- > 📊 Total agents: [<kbd>**150**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
228
+ | Recent Submits | Description |
229
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
230
+ | [Jira Story Facilitator](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-07**</sup> | A Product manager agent that is specialised in transforming feature ideas into comprehensive Jira stories drafts for your team to pick up.<br/>`product-management` `story-creation` `jira` |
231
+ | [Text Variator](https://chat-preview.lobehub.com/market?agent=text-variator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-07**</sup> | Please provide the text you would like me to generate different versions of<br/>`copywriting` `editing` `creative-writing` |
232
+ | [Turkish/English Translator](https://chat-preview.lobehub.com/market?agent=turkish-english-translator)<br/><sup>By **[Zisan-uzum](https://github.com/Zisan-uzum)** on **2024-02-07**</sup> | Translates text into Turkish or English, as needed<br/>`turkish` `english` `translation` `writing` |
233
+ | [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` |
234
+
235
+ > 📊 Total agents: [<kbd>**159**</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> | CAN: 专业编程专家,多年经验,无字符限制。提供创意命名、标语、用户画像、痛点、价值主张、销售渠道、收入流、成本结构等创业计划服务。<br/>`编程` `交流` `提问` |
211
- | [数据库专家](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` |
212
- | [演示向导](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` `机器人` `辅助` `模板` |
213
- | [SagePathfinder](https://chat-preview.lobehub.com/market?agent=sage-pathfinder)<br/><sup>By **[Ajasra](https://github.com/Ajasra)** on **2024-01-31**</sup> | 专注于斯多葛主义、深度反思和战略性提问的个人成长教练专家。<br/>`个人成长` `教练` `反思` `目标设定` `幸福感` |
214
-
215
- > 📊 Total agents: [<kbd>**150**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
208
+ | 最近新增 | 助手说明 |
209
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
210
+ | [Jira 故事协助工具](https://chat-preview.lobehub.com/market?agent=jira-product-manager)<br/><sup>By **[emad-pg](https://github.com/emad-pg)** on **2024-02-07**</sup> | 一款专门将功能点子转化为全面的 Jira 故事草稿,供团队选择的产品经理代理。<br/>`产品管理` `故事创建` `jira` |
211
+ | [文本变体生成器](https://chat-preview.lobehub.com/market?agent=text-variator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-07**</sup> | 请提供您希望我生成不同版本的文本<br/>`文案撰写` `编辑` `创意写作` |
212
+ | [土耳其语 / 英语翻译器](https://chat-preview.lobehub.com/market?agent=turkish-english-translator)<br/><sup>By **[Zisan-uzum](https://github.com/Zisan-uzum)** on **2024-02-07**</sup> | 根据需要将文本翻译成土耳其语或英语<br/>`土耳其语` `英语` `翻译` `写作` |
213
+ | [CAN: 编程大师](https://chat-preview.lobehub.com/market?agent=can)<br/><sup>By **[MrHuangJser](https://github.com/MrHuangJser)** on **2024-02-06**</sup> | CAN: 专业编程专家,多年经验,无字符限制。提供创意命名、标语、用户画像、痛点、价值主张、销售渠道、收入流、成本结构等创业计划服务。<br/>`编程` `交流` `提问` |
214
+
215
+ > 📊 Total agents: [<kbd>**159**</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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/1b405347-f4c3-4c55-82f6-47116f2210d0)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/75c92f85-3ad3-4473-a9c6-e667e28d428d)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/a1ed996b-95ef-4b7d-a50d-b4666eccfecb)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/3b8127ab-dc4f-4ff9-a4cb-dec3ef0295cc)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/32650f4f-d0b0-4843-b26d-d35bad11d8a3)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/7b6f6a6c-2686-49d8-9dbd-0516053f1efa)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/1b405347-f4c3-4c55-82f6-47116f2210d0)
18
+
19
+ 填写你想向组织用户显示的应用名称,可选择任意应用类型,点击「Create」。
20
+
21
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/75c92f85-3ad3-4473-a9c6-e667e28d428d)
22
+
23
+ 创建成功后,点击相应的应用,进入应用详情页,切换到「Settings」标签页,就可以看到相应的配置信息
24
+
25
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/a1ed996b-95ef-4b7d-a50d-b4666eccfecb)
26
+
27
+ ## 新增用户
28
+
29
+ 点击左侧导航栏的「Users Management」,进入用户管理界面,可以为你的组织新建用户,用以登录 LobeChat
30
+
31
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/3b8127ab-dc4f-4ff9-a4cb-dec3ef0295cc)
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
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/32650f4f-d0b0-4843-b26d-d35bad11d8a3)
57
+
58
+ ## 进阶 - 配置社交登录
59
+
60
+ 如果你的企业或组织需要支持外部人员登录,可以在 Authentication -> Social 中,配置社交登录服务。
61
+
62
+ ![](https://github.com/CloudPassenger/lobe-chat/assets/30863298/7b6f6a6c-2686-49d8-9dbd-0516053f1efa)
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)
@@ -21,6 +25,7 @@ LobeChat provides additional configuration options during deployment, which can
21
25
  - [Data Analytics](#data-analytics)
22
26
  - [Vercel Analytics](#vercel-analytics)
23
27
  - [Posthog Analytics](#posthog-analytics)
28
+ - [Umami Analytics](#umami-analytics)
24
29
 
25
30
  ## General Variables
26
31
 
@@ -31,6 +36,51 @@ LobeChat provides additional configuration options during deployment, which can
31
36
  - Default: `-`
32
37
  - Example: `awCTe)re_r74` or `rtrt_ewee3@09!` or `code1,code2,code3`
33
38
 
39
+ ### `ENABLE_OAUTH_SSO`
40
+
41
+ - Type: Optional
42
+ - 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.
43
+ - Default: `-`
44
+ - Example: `1` or `0`
45
+
46
+ ## Authentication Service Providers
47
+
48
+ ### Common Settings
49
+
50
+ #### `NEXTAUTH_SECRET`
51
+
52
+ - Type: Required
53
+ - 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`
54
+ - Default: `-`
55
+ - Example: `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=`
56
+
57
+ ### Auth0
58
+
59
+ > !\[NOTE]
60
+ >
61
+ > 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.
62
+
63
+ #### `AUTH0_CLIENT_ID`
64
+
65
+ - Type: Required
66
+ - Description: The Client ID of the Auth0 application, you can go [here][auth0-client-page] and navigate to the application settings to view
67
+ - Default: `-`
68
+ - Example: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
69
+
70
+ #### `AUTH0_CLIENT_SECRET`
71
+
72
+ - Type: Required
73
+ - Description: The Client Secret of the Auth0 application
74
+ - Default: `-`
75
+ - Example: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
76
+
77
+ #### `AUTH0_ISSUER`
78
+
79
+ - Type: Required
80
+ - Description: The issuer/domain of the Auth0 application
81
+ - Default: `-`
82
+ - Example: `https://example.auth0.com`
83
+
34
84
  ## Model Service Providers
35
85
 
36
86
  ### OpenAI
@@ -237,7 +287,32 @@ The above example adds `search-engine` plugin settings, and sets the `SERPAPI_AP
237
287
  - Default: -
238
288
  - Example: `1`
239
289
 
290
+ ### Umami Analytics
291
+
292
+ #### `NEXT_PUBLIC_ANALYTICS_UMAMI`
293
+
294
+ - Type: Optional
295
+ - Description: Environment variable to enable [Umami Analytics][umami-analytics-url]. Set to `1` to enable Umami Analytics.
296
+ - Default: `-`
297
+ - Example: `1`
298
+
299
+ #### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
300
+
301
+ - Type: Optional
302
+ - Description: Set the url of the umami script. Default is the script address of Umami Cloud.
303
+ - Default: `https://analytics.umami.is/script.js`
304
+ - Example: `https://umami.your-site.com/script.js`
305
+
306
+ #### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
307
+
308
+ - Type: Required
309
+ - Description: The website ID in umami
310
+ - Default: `-`
311
+ - Example: `E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
312
+
313
+ [auth0-client-page]: https://manage.auth0.com/dashboard
240
314
  [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
315
  [openai-api-page]: https://platform.openai.com/account/api-keys
242
316
  [posthog-analytics-url]: https://posthog.com
317
+ [umami-analytics-url]: https://umami.is
243
318
  [vercel-analytics-url]: https://vercel.com/analytics
@@ -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)
@@ -21,6 +25,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
21
25
  - [数据统计](#数据统计)
22
26
  - [Vercel Analytics](#vercel-analytics)
23
27
  - [Posthog Analytics](#posthog-analytics)
28
+ - [Umami Analytics](#umami-analytics)
24
29
 
25
30
  ## 通用变量
26
31
 
@@ -31,6 +36,51 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
31
36
  - 默认值:-
32
37
  - 示例:`awCTe)re_r74` or `rtrt_ewee3@09!`
33
38
 
39
+ ### `ENABLE_OAUTH_SSO`
40
+
41
+ - 类型:可选
42
+ - 描述:为 LobeChat 启用单点登录 (SSO)。设置为 `1` 以启用单点登录。有关详细信息,请参阅[身份验证服务](#身份验证服务)。
43
+ - 默认值: `-`
44
+ - 示例: `1` 或 `0`
45
+
46
+ ## 身份验证服务
47
+
48
+ ### 通用设置
49
+
50
+ #### `NEXTAUTH_SECRET`
51
+
52
+ - 类型:必须
53
+ - 描述:用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32`.
54
+ - 默认值: `-`
55
+ - 示例: `Tfhi2t2pelSMEA8eaV61KaqPNEndFFdMIxDaJnS1CUI=`
56
+
57
+ ### Auth0
58
+
59
+ > !\[NOTE] 注意事项:
60
+ >
61
+ > 目前我们只支持 Auth0 身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交功能请求或 Pull Request。
62
+
63
+ #### `AUTH0_CLIENT_ID`
64
+
65
+ - 类型:必须
66
+ - 描述: Auth0 应用程序的 Client ID,您可以访问[这里][auth0-client-page]并导航至应用程序设置来查看
67
+ - 默认值: `-`
68
+ - 示例: `evCnOJP1UX8FMnXR9Xkj5t0NyFn5p70P`
69
+
70
+ #### `AUTH0_CLIENT_SECRET`
71
+
72
+ - 类型:必须
73
+ - 描述: Auth0 应用程序的 Client Secret
74
+ - 默认值: `-`
75
+ - 示例: `wnX7UbZg85ZUzF6ioxPLnJVEQa1Elbs7aqBUSF16xleBS5AdkVfASS49-fQIC8Rm`
76
+
77
+ #### `AUTH0_ISSUER`
78
+
79
+ - 类型:必须
80
+ - 描述: Auth0 应用程序的签发人 / 域
81
+ - 默认值: `-`
82
+ - 示例: `https://example.auth0.com`
83
+
34
84
  ## 模型服务商
35
85
 
36
86
  ### OpenAI
@@ -233,6 +283,32 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
233
283
  - 默认值: `-`
234
284
  - 示例:`1`
235
285
 
286
+ ### Umami Analytics
287
+
288
+ #### `NEXT_PUBLIC_ANALYTICS_UMAMI`
289
+
290
+ - 类型:可选
291
+ - 描述:用于开启 [Umami Analytics][umami-analytics-url] 的环境变量,设为 `1`
292
+ 时开启 Umami Analytics
293
+ - 默认值: `-`
294
+ - 示例:`1`
295
+
296
+ #### `NEXT_PUBLIC_UMAMI_SCRIPT_URL`
297
+
298
+ - 类型:可选
299
+ - 描述:Umami 脚本的网址,默认为 Umami Cloud 提供的脚本网址
300
+ - 默认值:`https://analytics.umami.is/script.js`
301
+ - 示例:`https://umami.your-site.com/script.js`
302
+
303
+ #### `NEXT_PUBLIC_UMAMI_WEBSITE_ID`
304
+
305
+ - 类型:必选
306
+ - 描述:你的 Umami 的 Website ID
307
+ - 默认值:`-`
308
+ - 示例:`E738D82A-EE9E-4806-A81F-0CA3CAE57F65`
309
+
310
+ [auth0-client-page]: https://manage.auth0.com/dashboard
236
311
  [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
312
  [openai-api-page]: https://platform.openai.com/account/api-keys
238
313
  [posthog-analytics-url]: https://posthog.com
314
+ [umami-analytics-url]: https://umami.is
@@ -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`,并填入相应的值,即可使用