@lobehub/chat 0.126.1 → 0.126.2
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 +8 -0
- package/docs/Deployment/Authentication.zh-CN.md +9 -1
- package/docs/Deployment/Environment-Variable.md +2 -2
- package/docs/Deployment/Environment-Variable.zh-CN.md +2 -2
- package/docs/Development/{Authentication.md → Add-New-Authentication-Providers.md} +1 -1
- package/docs/Development/{Authentication.zh-CN.md → Add-New-Authentication-Providers.zh-CN.md} +1 -1
- package/docs/Home.md +2 -0
- package/docs/_Sidebar.md +2 -0
- package/package.json +1 -1
- package/src/app/api/auth/next-auth.ts +25 -0
- package/src/app/layout.tsx +5 -0
- package/src/config/server/app.ts +1 -0
- package/src/layout/GlobalLayout/index.tsx +17 -4
- package/src/middleware.ts +1 -1
- package/src/services/_url.ts +1 -0
- package/src/app/api/oauth/next-auth.ts +0 -21
- /package/src/app/api/{oauth → auth}/[...nextauth]/route.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.126.2](https://github.com/lobehub/lobe-chat/compare/v0.126.1...v0.126.2)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-02-09**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Fix OAuth throws an error on Vercel deploy.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Fix OAuth throws an error on Vercel deploy, closes [#1278](https://github.com/lobehub/lobe-chat/issues/1278) [#1277](https://github.com/lobehub/lobe-chat/issues/1277) [#1274](https://github.com/lobehub/lobe-chat/issues/1274) ([81d2d76](https://github.com/lobehub/lobe-chat/commit/81d2d76))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 0.126.1](https://github.com/lobehub/lobe-chat/compare/v0.126.0...v0.126.1)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-02-09**</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
|
-
| [
|
|
231
|
-
| [
|
|
232
|
-
| [
|
|
233
|
-
| [
|
|
234
|
-
|
|
235
|
-
> 📊 Total agents: [<kbd>**
|
|
228
|
+
| Recent Submits | Description |
|
|
229
|
+
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
230
|
+
| [Vocabulary Wizard](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in generating vocabulary lists and MCQ tests<br/>`vocabulary` `academic-word-list` `language-learning` `testing` |
|
|
231
|
+
| [English Proficiency Evaluator](https://chat-preview.lobehub.com/market?agent=english-proficiency-assessor)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in creating adaptive English proficiency diagnostic tests<br/>`test-creation` `english-proficiency` `assessment` |
|
|
232
|
+
| [Glossary Generator](https://chat-preview.lobehub.com/market?agent=glossary-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Expert in generating glossaries with English definitions and example sentences<br/>`glossary` `translation` `language` |
|
|
233
|
+
| [Grammar Worksheet Creator](https://chat-preview.lobehub.com/market?agent=grammar-revision-worksheets)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | Specializes in creating English grammar learning materials and exercises<br/>`english-grammar` `worksheet` `learning` `practice` `mc-qs` |
|
|
234
|
+
|
|
235
|
+
> 📊 Total agents: [<kbd>**170**</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
|
-
| [
|
|
211
|
-
| [
|
|
212
|
-
| [
|
|
213
|
-
| [
|
|
214
|
-
|
|
215
|
-
> 📊 Total agents: [<kbd>**
|
|
208
|
+
| 最近新增 | 助手说明 |
|
|
209
|
+
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
|
|
210
|
+
| [词汇大师](https://chat-preview.lobehub.com/market?agent=awl-vocab-wizard)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 擅长生成词汇列表和多项选择测试<br/>`词汇` `学术词汇表` `语言学习` `测试` |
|
|
211
|
+
| [英语熟练度评估器](https://chat-preview.lobehub.com/market?agent=english-proficiency-assessor)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 专业创建自适应英语熟练度诊断测试的专家<br/>`测试创建` `英语熟练度` `评估` |
|
|
212
|
+
| [术语表生成器](https://chat-preview.lobehub.com/market?agent=glossary-generator)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 擅长生成带有英文定义和例句的术语表<br/>`术语表` `翻译` `语言` |
|
|
213
|
+
| [语法工作表生成器](https://chat-preview.lobehub.com/market?agent=grammar-revision-worksheets)<br/><sup>By **[bentwnghk](https://github.com/bentwnghk)** on **2024-02-09**</sup> | 专注于创建英语语法学习材料和练习<br/>`english-grammar` `worksheet` `learning` `practice` `mc-qs` |
|
|
214
|
+
|
|
215
|
+
> 📊 Total agents: [<kbd>**170**</kbd> ](https://github.com/lobehub/lobe-chat-agents)
|
|
216
216
|
|
|
217
217
|
<!-- AGENT LIST -->
|
|
218
218
|
|
|
@@ -24,6 +24,14 @@ Once the application is successfully created, click on the respective applicatio
|
|
|
24
24
|
|
|
25
25
|

|
|
26
26
|
|
|
27
|
+
On the application configuration page, you also need to configure the **_Allowed Callback URLs_** to be `http(s)://<your-domain>/api/auth/callback/auth0`
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
> \[!NOTE]
|
|
32
|
+
>
|
|
33
|
+
> You can fill in or modify the Allowed Callback URLs after deployment, but make sure the URLs are consistent with the deployed URLs!
|
|
34
|
+
|
|
27
35
|
## Adding Users
|
|
28
36
|
|
|
29
37
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 身份验证服务
|
|
2
2
|
|
|
3
|
-
LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权,目前支持 [Auth0][auth0-client-page]
|
|
3
|
+
LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用,统一管理用户授权,目前支持 [Auth0][auth0-client-page],本文将介绍如何配置身份验证服务。
|
|
4
4
|
|
|
5
5
|
### TOC
|
|
6
6
|
|
|
@@ -24,6 +24,14 @@ LobeChat 支持配置外部身份验证服务,供企业 / 组织内部使用
|
|
|
24
24
|
|
|
25
25
|

|
|
26
26
|
|
|
27
|
+
在应用配置页面中,还需要配置 Allowed Callback URLs,在此处填写 `http(s)://<your-domain>/api/auth/callback/auth0`
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
> \[!NOTE]
|
|
32
|
+
>
|
|
33
|
+
> 可以在部署后再填写或修改 Allowed Callback URLs,但是务必保证填写的 URL 与部署的 URL 一致
|
|
34
|
+
|
|
27
35
|
## 新增用户
|
|
28
36
|
|
|
29
37
|
点击左侧导航栏的「Users Management」,进入用户管理界面,可以为你的组织新建用户,用以登录 LobeChat
|
|
@@ -64,7 +64,7 @@ LobeChat provides additional configuration options during deployment, which can
|
|
|
64
64
|
|
|
65
65
|
### Auth0
|
|
66
66
|
|
|
67
|
-
>
|
|
67
|
+
> \[!NOTE]
|
|
68
68
|
>
|
|
69
69
|
> 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.
|
|
70
70
|
|
|
@@ -107,7 +107,7 @@ LobeChat provides additional configuration options during deployment, which can
|
|
|
107
107
|
- Default: `https://api.openai.com/v1`
|
|
108
108
|
- Example: `https://api.chatanywhere.cn` or `https://aihubmix.com/v1`
|
|
109
109
|
|
|
110
|
-
>
|
|
110
|
+
> \[!NOTE]
|
|
111
111
|
>
|
|
112
112
|
> Please check the request suffix of your proxy service provider. Some proxy service providers may add `/v1` to the request suffix, while others may not.
|
|
113
113
|
> If you find that the AI returns an empty message during testing, try adding the `/v1` suffix and retrying.
|
|
@@ -64,7 +64,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
64
64
|
|
|
65
65
|
### Auth0
|
|
66
66
|
|
|
67
|
-
>
|
|
67
|
+
> \[!NOTE] 注意事项:
|
|
68
68
|
>
|
|
69
69
|
> 目前我们只支持 Auth0 身份验证服务提供商。如果您需要使用其他身份验证服务提供商,可以提交功能请求或 Pull Request。
|
|
70
70
|
|
|
@@ -107,7 +107,7 @@ LobeChat 在部署时提供了一些额外的配置项,使用环境变量进
|
|
|
107
107
|
- 默认值:`https://api.openai.com/v1`
|
|
108
108
|
- 示例:`https://api.chatanywhere.cn` 或 `https://aihubmix.com/v1`
|
|
109
109
|
|
|
110
|
-
>
|
|
110
|
+
> \[!NOTE] 注意事项:
|
|
111
111
|
>
|
|
112
112
|
> 请检查你的代理服务商的请求后缀,有的代理服务商会在请求后缀添加 `/v1`,有的则不会。
|
|
113
113
|
> 如果你在测试时发现 AI 返回的消息为空,请尝试添加 `/v1` 后缀后重试。
|
|
@@ -23,7 +23,7 @@ Next, I will use [Okta](https://authjs.dev/reference/core/providers/okta) as an
|
|
|
23
23
|
|
|
24
24
|
### Step 1: Add Authenticator Core Code
|
|
25
25
|
|
|
26
|
-
Open the `src/app/api/
|
|
26
|
+
Open the `src/app/api/auth/next-auth.ts` file and import `next-auth/providers/okta`.
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
import { NextAuth } from 'next-auth';
|
package/docs/Development/{Authentication.zh-CN.md → Add-New-Authentication-Providers.zh-CN.md}
RENAMED
|
@@ -23,7 +23,7 @@ LobeChat 使用 [Auth.js v5](https://authjs.dev/) 作为外部身份验证服务
|
|
|
23
23
|
|
|
24
24
|
### 步骤 1: 新增关键代码
|
|
25
25
|
|
|
26
|
-
打开 `src/app/api/
|
|
26
|
+
打开 `src/app/api/auth/next-auth.ts` 文件,引入 `next-auth/providers/okta`
|
|
27
27
|
|
|
28
28
|
```ts
|
|
29
29
|
import { NextAuth } from 'next-auth';
|
package/docs/Home.md
CHANGED
|
@@ -27,6 +27,7 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
|
|
|
27
27
|
- [Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment) | [Docker 部署指引](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
|
|
28
28
|
- [Deploying with Azure OpenAI](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI.zh-CN)
|
|
29
29
|
- [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
30
|
+
- [Authentication Service](https://github.com/lobehub/lobe-chat/wiki/Authentication) | [身份验证服务](https://github.com/lobehub/lobe-chat/wiki/Authentication.zh-CN)
|
|
30
31
|
- [Upstream Sync](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync) | [自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
|
|
31
32
|
- [Frequently Asked Questions](https://github.com/lobehub/lobe-chat/wiki/Common-Error) | [常见问题](https://github.com/lobehub/lobe-chat/wiki/Common-Error.zh-CN)
|
|
32
33
|
- [Data Statistics](https://github.com/lobehub/lobe-chat/wiki/Analytics) | [数据统计](https://github.com/lobehub/lobe-chat/wiki/Analytics.zh-CN)
|
|
@@ -47,6 +48,7 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
|
|
|
47
48
|
- [Frontend](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend) | [前端实现](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend.zh-CN)
|
|
48
49
|
- [Internationalization Implementation Guide](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation) | [国际化实现指南](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation.zh-CN)
|
|
49
50
|
- [New Locale Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale) | [新语种添加指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale.zh-CN)
|
|
51
|
+
- [New Authentication Provider Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers) | [新身份验证方式开发指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers.zh-CN)
|
|
50
52
|
- [Testing Guide](https://github.com/lobehub/lobe-chat/wiki/Test) | [测试指南](https://github.com/lobehub/lobe-chat/wiki/Test.zh-CN)
|
|
51
53
|
- [Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources) | [资源与参考](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN)
|
|
52
54
|
|
package/docs/_Sidebar.md
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
- [Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment) | [Docker 部署指引](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
|
|
18
18
|
- [Deploying with Azure OpenAI](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI.zh-CN)
|
|
19
19
|
- [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
20
|
+
- [Authentication Service](https://github.com/lobehub/lobe-chat/wiki/Authentication) | [身份验证服务](https://github.com/lobehub/lobe-chat/wiki/Authentication.zh-CN)
|
|
20
21
|
- [Upstream Sync](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync) | [自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
|
|
21
22
|
- [Frequently Asked Questions](https://github.com/lobehub/lobe-chat/wiki/Common-Error) | [常见问题](https://github.com/lobehub/lobe-chat/wiki/Common-Error.zh-CN)
|
|
22
23
|
- [Data Statistics](https://github.com/lobehub/lobe-chat/wiki/Analytics) | [数据统计](https://github.com/lobehub/lobe-chat/wiki/Analytics.zh-CN)
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
- [Frontend](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend) | [前端实现](https://github.com/lobehub/lobe-chat/wiki/Feature-Development-Frontend.zh-CN)
|
|
36
37
|
- [Internationalization Implementation Guide](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation) | [国际化实现指南](https://github.com/lobehub/lobe-chat/wiki/Internationalization-Implementation.zh-CN)
|
|
37
38
|
- [New Locale Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale) | [新语种添加指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Locale.zh-CN)
|
|
39
|
+
- [New Authentication Provider Guide](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers) | [新身份验证方式开发指南](https://github.com/lobehub/lobe-chat/wiki/Add-New-Authentication-Providers.zh-CN)
|
|
38
40
|
- [Testing Guide](https://github.com/lobehub/lobe-chat/wiki/Test) | [测试指南](https://github.com/lobehub/lobe-chat/wiki/Test.zh-CN)
|
|
39
41
|
- [Resources and References](https://github.com/lobehub/lobe-chat/wiki/Resources) | [资源与参考](https://github.com/lobehub/lobe-chat/wiki/Resources.zh-CN)
|
|
40
42
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.126.
|
|
3
|
+
"version": "0.126.2",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import NextAuth from 'next-auth';
|
|
2
|
+
import Auth0 from 'next-auth/providers/auth0';
|
|
3
|
+
|
|
4
|
+
import { getServerConfig } from '@/config/server';
|
|
5
|
+
|
|
6
|
+
const { AUTH0_CLIENT_ID, ENABLE_OAUTH_SSO, AUTH0_CLIENT_SECRET, AUTH0_ISSUER, NEXTAUTH_SECRET } =
|
|
7
|
+
getServerConfig();
|
|
8
|
+
|
|
9
|
+
const nextAuth = NextAuth({
|
|
10
|
+
providers: ENABLE_OAUTH_SSO
|
|
11
|
+
? [
|
|
12
|
+
Auth0({
|
|
13
|
+
clientId: AUTH0_CLIENT_ID,
|
|
14
|
+
clientSecret: AUTH0_CLIENT_SECRET,
|
|
15
|
+
issuer: AUTH0_ISSUER,
|
|
16
|
+
}),
|
|
17
|
+
]
|
|
18
|
+
: [],
|
|
19
|
+
secret: NEXTAUTH_SECRET,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const {
|
|
23
|
+
handlers: { GET, POST },
|
|
24
|
+
auth,
|
|
25
|
+
} = nextAuth;
|
package/src/app/layout.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { PropsWithChildren } from 'react';
|
|
|
4
4
|
import { isRtlLang } from 'rtl-detect';
|
|
5
5
|
|
|
6
6
|
import Analytics from '@/components/Analytics';
|
|
7
|
+
import { getServerConfig } from '@/config/server';
|
|
7
8
|
import { DEFAULT_LANG, LOBE_LOCALE_COOKIE } from '@/const/locale';
|
|
8
9
|
import {
|
|
9
10
|
LOBE_THEME_APPEARANCE,
|
|
@@ -14,6 +15,8 @@ import Layout from '@/layout/GlobalLayout';
|
|
|
14
15
|
|
|
15
16
|
import StyleRegistry from './StyleRegistry';
|
|
16
17
|
|
|
18
|
+
const { ENABLE_OAUTH_SSO } = getServerConfig();
|
|
19
|
+
|
|
17
20
|
const RootLayout = ({ children }: PropsWithChildren) => {
|
|
18
21
|
// get default theme config to use with ssr
|
|
19
22
|
const cookieStore = cookies();
|
|
@@ -22,6 +25,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
|
|
|
22
25
|
const primaryColor = cookieStore.get(LOBE_THEME_PRIMARY_COLOR);
|
|
23
26
|
const lang = cookieStore.get(LOBE_LOCALE_COOKIE);
|
|
24
27
|
const direction = isRtlLang(lang?.value || DEFAULT_LANG) ? 'rtl' : 'ltr';
|
|
28
|
+
|
|
25
29
|
return (
|
|
26
30
|
<html dir={direction} lang={lang?.value || DEFAULT_LANG} suppressHydrationWarning>
|
|
27
31
|
<body>
|
|
@@ -31,6 +35,7 @@ const RootLayout = ({ children }: PropsWithChildren) => {
|
|
|
31
35
|
defaultLang={lang?.value}
|
|
32
36
|
defaultNeutralColor={neutralColor?.value as any}
|
|
33
37
|
defaultPrimaryColor={primaryColor?.value as any}
|
|
38
|
+
enableOAuthSSO={ENABLE_OAUTH_SSO}
|
|
34
39
|
>
|
|
35
40
|
{children}
|
|
36
41
|
</Layout>
|
package/src/config/server/app.ts
CHANGED
|
@@ -52,5 +52,6 @@ export const getAppConfig = () => {
|
|
|
52
52
|
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID || '',
|
|
53
53
|
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET || '',
|
|
54
54
|
AUTH0_ISSUER: process.env.AUTH0_ISSUER || '',
|
|
55
|
+
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET || '',
|
|
55
56
|
};
|
|
56
57
|
};
|
|
@@ -8,6 +8,7 @@ import dynamic from 'next/dynamic';
|
|
|
8
8
|
import { FC, PropsWithChildren, memo } from 'react';
|
|
9
9
|
|
|
10
10
|
import { getClientConfig } from '@/config/client';
|
|
11
|
+
import { API_ENDPOINTS } from '@/services/_url';
|
|
11
12
|
|
|
12
13
|
import AppTheme, { AppThemeProps } from './AppTheme';
|
|
13
14
|
import Locale from './Locale';
|
|
@@ -45,10 +46,16 @@ const Container = memo<PropsWithChildren>(({ children }) => {
|
|
|
45
46
|
|
|
46
47
|
interface GlobalLayoutProps extends AppThemeProps {
|
|
47
48
|
defaultLang?: string;
|
|
49
|
+
enableOAuthSSO?: boolean;
|
|
48
50
|
}
|
|
49
51
|
|
|
50
|
-
const GlobalLayout = ({
|
|
51
|
-
|
|
52
|
+
const GlobalLayout = ({
|
|
53
|
+
children,
|
|
54
|
+
defaultLang,
|
|
55
|
+
enableOAuthSSO = false,
|
|
56
|
+
...theme
|
|
57
|
+
}: GlobalLayoutProps) => {
|
|
58
|
+
const content = (
|
|
52
59
|
<AppTheme {...theme}>
|
|
53
60
|
<Locale defaultLang={defaultLang}>
|
|
54
61
|
<StoreHydration />
|
|
@@ -56,7 +63,13 @@ const GlobalLayout = ({ children, defaultLang, ...theme }: GlobalLayoutProps) =>
|
|
|
56
63
|
<DebugUI />
|
|
57
64
|
</Locale>
|
|
58
65
|
</AppTheme>
|
|
59
|
-
|
|
60
|
-
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return enableOAuthSSO ? (
|
|
69
|
+
<SessionProvider basePath={API_ENDPOINTS.oauth}>{content}</SessionProvider>
|
|
70
|
+
) : (
|
|
71
|
+
content
|
|
72
|
+
);
|
|
73
|
+
};
|
|
61
74
|
|
|
62
75
|
export default GlobalLayout;
|
package/src/middleware.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// export { auth as middleware } from './app/api/next-auth';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
3
|
|
|
4
|
-
import { auth } from './app/api/
|
|
4
|
+
import { auth } from './app/api/auth/next-auth';
|
|
5
5
|
import { OAUTH_AUTHORIZED } from './const/auth';
|
|
6
6
|
|
|
7
7
|
export const config = {
|
package/src/services/_url.ts
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import NextAuth from 'next-auth';
|
|
2
|
-
import Auth0 from 'next-auth/providers/auth0';
|
|
3
|
-
|
|
4
|
-
import { getServerConfig } from '@/config/server';
|
|
5
|
-
|
|
6
|
-
const { AUTH0_CLIENT_ID, AUTH0_CLIENT_SECRET, AUTH0_ISSUER } = getServerConfig();
|
|
7
|
-
|
|
8
|
-
const nextAuth = NextAuth({
|
|
9
|
-
providers: [
|
|
10
|
-
Auth0({
|
|
11
|
-
clientId: AUTH0_CLIENT_ID,
|
|
12
|
-
clientSecret: AUTH0_CLIENT_SECRET,
|
|
13
|
-
issuer: AUTH0_ISSUER,
|
|
14
|
-
}),
|
|
15
|
-
],
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export const {
|
|
19
|
-
handlers: { GET, POST },
|
|
20
|
-
auth,
|
|
21
|
-
} = nextAuth;
|
|
File without changes
|