@lobehub/chat 1.13.2 → 1.14.1
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 +50 -0
- package/Dockerfile +1 -1
- package/README.ja-JP.md +809 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.mdx +68 -0
- package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.zh-CN.mdx +63 -0
- package/docs/self-hosting/environment-variables/auth.mdx +23 -0
- package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +23 -0
- package/package.json +1 -1
- package/src/config/auth.ts +20 -0
- package/src/config/llm.ts +2 -0
- package/src/config/modelProviders/zhipu.ts +2 -0
- package/src/libs/next-auth/auth.config.ts +1 -1
- package/src/libs/next-auth/sso-providers/cloudflare-zero-trust.ts +35 -0
- package/src/libs/next-auth/sso-providers/index.ts +3 -1
- package/src/libs/next-auth/sso-providers/logto.ts +50 -0
- package/src/server/globalConfig/index.ts +11 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ An open-source, modern-design ChatGPT/LLMs UI/Framework.<br/>
|
|
|
8
8
|
Supports speech-synthesis, multi-modal, and extensible ([function call][docs-functionc-call]) plugin system.<br/>
|
|
9
9
|
One-click **FREE** deployment of your private OpenAI ChatGPT/Claude/Gemini/Groq/Ollama chat application.
|
|
10
10
|
|
|
11
|
-
**English** · [简体中文](./README.zh-CN.md) · [Official Site][official-site] · [Changelog](./CHANGELOG.md) · [Documents][docs] · [Blog][blog] · [Feedback][github-issues-link]
|
|
11
|
+
**English** · [简体中文](./README.zh-CN.md) · [日本語](./README.ja-JP.md) · [Official Site][official-site] · [Changelog](./CHANGELOG.md) · [Documents][docs] · [Blog][blog] · [Feedback][github-issues-link]
|
|
12
12
|
|
|
13
13
|
<!-- SHIELD GROUP -->
|
|
14
14
|
|
package/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
支持语音合成、多模态、可扩展的([function call][docs-functionc-call])插件系统<br/>
|
|
9
9
|
一键**免费**拥有你自己的 ChatGPT/Gemini/Claude/Ollama 应用
|
|
10
10
|
|
|
11
|
-
[English](./README.md) · **简体中文** · [官网][official-site] · [更新日志](./CHANGELOG.md) · [文档][docs] · [博客][blog] · [反馈问题][github-issues-link]
|
|
11
|
+
[English](./README.md) · **简体中文** · [日本語](./README.ja-JP.md) · [官网][official-site] · [更新日志](./CHANGELOG.md) · [文档][docs] · [博客][blog] · [反馈问题][github-issues-link]
|
|
12
12
|
|
|
13
13
|
<!-- SHIELD GROUP -->
|
|
14
14
|
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configuring Cloudflare Zero Trust Authentication Service for LobeChat
|
|
3
|
+
description: >-
|
|
4
|
+
Learn how to configure Cloudflare Zero Trust for Single Sign-On (SSO) for LobeChat,
|
|
5
|
+
including creating an application provider, setting environment variables, and
|
|
6
|
+
deployment instructions.
|
|
7
|
+
tags:
|
|
8
|
+
- Cloudflare Zero Trust
|
|
9
|
+
- Single Sign-On (SSO)
|
|
10
|
+
- LobeChat Authentication
|
|
11
|
+
- Environment Variables
|
|
12
|
+
- Deployment Instructions
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Configuring Cloudflare Zero Trust Authentication Service
|
|
16
|
+
|
|
17
|
+
## Cloudflare Zero Trust Configuration Flow
|
|
18
|
+
|
|
19
|
+
<Steps>
|
|
20
|
+
### Creating an Application in Cloudflare Zero Trust
|
|
21
|
+
|
|
22
|
+
We assume you are already familiar with using the Cloudflare Zero Trust platform and that your LobeChat instance is deployed at `https://chat.example.com`.
|
|
23
|
+
|
|
24
|
+
First, we need to visit `https://one.dash.cloudflare.com/` and navigate to `Access - Applications`.
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
Now, on the current page, click `Add an application` and select `SaaS`.
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
In the `Application` text box, enter the application name, such as `LobeChat SSO`. Then click `Select OIDC`, followed by clicking `Add application`.
|
|
33
|
+
|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
At this point, you have successfully created a SaaS application named `LobeChat SSO` in Cloudflare Zero Trust.
|
|
37
|
+
|
|
38
|
+
Next, we need to enter `https://chat.example.com/api/auth/callback/cloudflare-zero-trust` in the `Redirect URLs` field (note that `chat.example.com` should be replaced with your instance's address).
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
Finally, scroll down the page and record the following three values: `Client secret`, `Client ID`, and `Issuer`. You will need these for setting the environment variables when deploying LobeChat.
|
|
43
|
+
|
|
44
|
+

|
|
45
|
+
|
|
46
|
+
### Configure Environment Variables
|
|
47
|
+
|
|
48
|
+
When deploying LobeChat, you need to configure the following environment variables:
|
|
49
|
+
|
|
50
|
+
| Environment Variable | Type | Description |
|
|
51
|
+
| --- | --- | --- |
|
|
52
|
+
| `NEXT_AUTH_SECRET` | Required | The secret used to encrypt Auth.js session tokens. You can generate a secret using the following command: `openssl rand -base64 32` |
|
|
53
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | Required | Select the SSO provider for LoboChat. Use `cloudflare-zero-trust` for Cloudflare Zero Trust. |
|
|
54
|
+
| `CLOUDFLARE_ZERO_TRUST_CLIENT_ID` | Required | The Client ID from the Cloudflare Zero Trust application provider details page |
|
|
55
|
+
| `CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET` | Required | The Client Secret from the Cloudflare Zero Trust application provider details page |
|
|
56
|
+
| `CLOUDFLARE_ZERO_TRUST_ISSUER` | Required | The OpenID Configuration Issuer from the Cloudflare Zero Trust application provider details page |
|
|
57
|
+
| `NEXTAUTH_URL` | Optional | This URL is used to specify the callback address for Auth.js when performing OAuth authentication. It only needs to be set when the default generated redirect address is incorrect. `https://example.com/api/auth` |
|
|
58
|
+
|
|
59
|
+
<Callout type={'tip'}>
|
|
60
|
+
Go to [📘 Environment Variables](/docs/self-hosting/environment-variable#Cloudflare%20Zero%20Trust) for details about the variables.
|
|
61
|
+
|
|
62
|
+
</Callout>
|
|
63
|
+
</Steps>
|
|
64
|
+
|
|
65
|
+
<Callout type={'info'}>
|
|
66
|
+
After a successful deployment, users will be able to use LobeChat by authenticating with the users
|
|
67
|
+
configured in Cloudflare Zero Trust.
|
|
68
|
+
</Callout>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 在 LobeChat 中配置 Cloudflare Zero Trust 身份验证服务
|
|
3
|
+
description: 学习如何在 LobeChat 中配置 Cloudflare Zero Trust 身份验证服务,包括创建提供程序、配置环境变量和部署 LobeChat。详细步骤和必要环境变量设置。
|
|
4
|
+
tags:
|
|
5
|
+
- Cloudflare Zero Trust
|
|
6
|
+
- 身份验证
|
|
7
|
+
- 单点登录
|
|
8
|
+
- 环境变量
|
|
9
|
+
- LobeChat
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# 配置 Cloudflare Zero Trust 身份验证服务
|
|
13
|
+
|
|
14
|
+
## Cloudflare Zero Trust 配置流程
|
|
15
|
+
|
|
16
|
+
<Steps>
|
|
17
|
+
### 在 Cloudflare Zero Trust 中创建应用
|
|
18
|
+
|
|
19
|
+
我们现在默认您已经了解了如何使用 Cloudflare Zero Trust 平台且假设您的 LobeChat 实例部署在 `https://chat.example.com` 中。
|
|
20
|
+
|
|
21
|
+
首先我们需要访问 `https://one.dash.cloudflare.com/` 并前往 `Access - Applications` 中。
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
现在,在所在页面点击 `Add an application` 并选择 `SaaS`。
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
在 `Application` 文本框内填入应用名称,如:`LobeChat SSO`,然后点击 `Select OIDC` 后点击 `Add applicaiton`
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
至此您已成功在 Clouflare Zero Trust 中创建了一个名为 `LobeChat SSO` 的 SaaS 应用。
|
|
34
|
+
|
|
35
|
+
接下来我们需要在 `Redirect URLs` 中填入 `https://chat.example.com/api/auth/callback/cloudflare-zero-trust`(注意此处的 `chat.example.com` 需要替换为您的实例地址)
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
最后我们将页面往下滚动,您将需要记录以下三个值 `Client secret`, `Client ID` 及 `Issuer` 以备后续部署 LobeChat 环境变量使用。
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
### 配置环境变量
|
|
43
|
+
|
|
44
|
+
在部署 LobeChat 时,你需要配置以下环境变量:
|
|
45
|
+
|
|
46
|
+
| 环境变量 | 类型 | 描述 |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
|
|
49
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Cloudflare Zero Trust 请填写 `cloudflare-zero-trust`。 |
|
|
50
|
+
| `CLOUDFLARE_ZERO_TRUST_CLIENT_ID` | 必选 | 在 Cloudflare Zero Trust 生成的 `Client ID`,示例值是 `lobe-chat` |
|
|
51
|
+
| `CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET` | 必选 | 在 Cloudflare Zero Trust 生成的 `Client secret`,示例值是 `insecure_secret` |
|
|
52
|
+
| `CLOUDFLARE_ZERO_TRUST_ISSUER` | 必选 | 在 Cloudflare Zero Trust 生成的 `Issuer`,例如 `https://example.cloudflareaccess.com/cdn-cgi/access/sso/oidc/7db0f` |
|
|
53
|
+
| `NEXTAUTH_URL` | 可选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://chat.example.com/api/auth` |
|
|
54
|
+
|
|
55
|
+
<Callout type={'tip'}>
|
|
56
|
+
前往 [📘 环境变量](/docs/self-hosting/environment-variable#Cloudflare%20Zero%20Trust) 可查阅相关变量详情。
|
|
57
|
+
|
|
58
|
+
</Callout>
|
|
59
|
+
</Steps>
|
|
60
|
+
|
|
61
|
+
<Callout type={'info'}>
|
|
62
|
+
部署成功后,用户将可以使用 Cloudflare Zero Trust 中配置的用户通过身份认证并使用 LobeChat。
|
|
63
|
+
</Callout>
|
|
@@ -132,6 +132,29 @@ LobeChat provides a complete authentication service capability when deployed. Th
|
|
|
132
132
|
- Default: `-`
|
|
133
133
|
- Example: `https://sso.example.com`
|
|
134
134
|
|
|
135
|
+
### Cloudflare Zero Trust
|
|
136
|
+
|
|
137
|
+
#### `CLOUDFLARE_ZERO_TRUST_CLIENT_ID`
|
|
138
|
+
|
|
139
|
+
- Type: Required
|
|
140
|
+
- Description: Client ID of the Cloudflare Zero Trust provider application. You can access it [here][auth0-client-page] and navigate to the application settings to view.
|
|
141
|
+
- Default: `-`
|
|
142
|
+
- Example: `lobe-chat`
|
|
143
|
+
|
|
144
|
+
#### `CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET`
|
|
145
|
+
|
|
146
|
+
- Type: Required
|
|
147
|
+
- Description: The plaintext of the Client Secret for the Cloudflare Zero Trust provider
|
|
148
|
+
- Default: `-`
|
|
149
|
+
- Example: `insecure_secret`
|
|
150
|
+
|
|
151
|
+
#### `CLOUDFLARE_ZERO_TRUST_ISSUER`
|
|
152
|
+
|
|
153
|
+
- Type: Required
|
|
154
|
+
- Description: Issuer of the Cloudflare Zero Trust provider application.
|
|
155
|
+
- Default: `-`
|
|
156
|
+
- Example: `https://sso.example.com`
|
|
157
|
+
|
|
135
158
|
### Github
|
|
136
159
|
|
|
137
160
|
#### `GITHUB_CLIENT_ID`
|
|
@@ -130,6 +130,29 @@ LobeChat 在部署时提供了完善的身份验证服务能力,以下是相
|
|
|
130
130
|
- 默认值: `-`
|
|
131
131
|
- 示例: `https://sso.example.com`
|
|
132
132
|
|
|
133
|
+
### Cloudflare Zero Trust
|
|
134
|
+
|
|
135
|
+
#### `CLOUDFLARE_ZERO_TRUST_CLIENT_ID`
|
|
136
|
+
|
|
137
|
+
- 类型:必选
|
|
138
|
+
- 描述: Cloudflare Zero Trust 提供程序的 Client ID
|
|
139
|
+
- 默认值: `-`
|
|
140
|
+
- 示例: `lobe-chat`
|
|
141
|
+
|
|
142
|
+
#### `CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET`
|
|
143
|
+
|
|
144
|
+
- 类型:必选
|
|
145
|
+
- 描述: Cloudflare Zero Trust 提供程序的 Client Secret 的明文
|
|
146
|
+
- 默认值: `-`
|
|
147
|
+
- 示例: `insecure_secret`
|
|
148
|
+
|
|
149
|
+
#### `CLOUDFLARE_ZERO_TRUST_ISSUER`
|
|
150
|
+
|
|
151
|
+
- 类型:必选
|
|
152
|
+
- 描述: Cloudflare Zero Trust 提供程序的 OpenID Connect 颁发者
|
|
153
|
+
- 默认值: `-`
|
|
154
|
+
- 示例: `https://sso.example.com`
|
|
155
|
+
|
|
133
156
|
### Github
|
|
134
157
|
|
|
135
158
|
#### `GITHUB_CLIENT_ID`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.1",
|
|
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",
|
package/src/config/auth.ts
CHANGED
|
@@ -86,10 +86,20 @@ export const getAuthConfig = () => {
|
|
|
86
86
|
AUTHELIA_CLIENT_SECRET: z.string().optional(),
|
|
87
87
|
AUTHELIA_ISSUER: z.string().optional(),
|
|
88
88
|
|
|
89
|
+
// Cloudflare Zero Trust
|
|
90
|
+
CLOUDFLARE_ZERO_TRUST_CLIENT_ID: z.string().optional(),
|
|
91
|
+
CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET: z.string().optional(),
|
|
92
|
+
CLOUDFLARE_ZERO_TRUST_ISSUER: z.string().optional(),
|
|
93
|
+
|
|
89
94
|
// ZITADEL
|
|
90
95
|
ZITADEL_CLIENT_ID: z.string().optional(),
|
|
91
96
|
ZITADEL_CLIENT_SECRET: z.string().optional(),
|
|
92
97
|
ZITADEL_ISSUER: z.string().optional(),
|
|
98
|
+
|
|
99
|
+
// LOGTO
|
|
100
|
+
LOGTO_CLIENT_ID: z.string().optional(),
|
|
101
|
+
LOGTO_CLIENT_SECRET: z.string().optional(),
|
|
102
|
+
LOGTO_ISSUER: z.string().optional(),
|
|
93
103
|
},
|
|
94
104
|
|
|
95
105
|
runtimeEnv: {
|
|
@@ -128,10 +138,20 @@ export const getAuthConfig = () => {
|
|
|
128
138
|
AUTHELIA_CLIENT_SECRET: process.env.AUTHELIA_CLIENT_SECRET,
|
|
129
139
|
AUTHELIA_ISSUER: process.env.AUTHELIA_ISSUER,
|
|
130
140
|
|
|
141
|
+
// Cloudflare Zero Trust
|
|
142
|
+
CLOUDFLARE_ZERO_TRUST_CLIENT_ID: process.env.CLOUDFLARE_ZERO_TRUST_CLIENT_ID,
|
|
143
|
+
CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET: process.env.CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET,
|
|
144
|
+
CLOUDFLARE_ZERO_TRUST_ISSUER: process.env.CLOUDFLARE_ZERO_TRUST_ISSUER,
|
|
145
|
+
|
|
131
146
|
// ZITADEL
|
|
132
147
|
ZITADEL_CLIENT_ID: process.env.ZITADEL_CLIENT_ID,
|
|
133
148
|
ZITADEL_CLIENT_SECRET: process.env.ZITADEL_CLIENT_SECRET,
|
|
134
149
|
ZITADEL_ISSUER: process.env.ZITADEL_ISSUER,
|
|
150
|
+
|
|
151
|
+
// LOGTO
|
|
152
|
+
LOGTO_CLIENT_ID: process.env.LOGTO_CLIENT_ID,
|
|
153
|
+
LOGTO_CLIENT_SECRET: process.env.LOGTO_CLIENT_SECRET,
|
|
154
|
+
LOGTO_ISSUER: process.env.LOGTO_ISSUER,
|
|
135
155
|
},
|
|
136
156
|
});
|
|
137
157
|
};
|
package/src/config/llm.ts
CHANGED
|
@@ -20,6 +20,7 @@ export const getLLMConfig = () => {
|
|
|
20
20
|
|
|
21
21
|
ENABLED_ZHIPU: z.boolean(),
|
|
22
22
|
ZHIPU_API_KEY: z.string().optional(),
|
|
23
|
+
ZHIPU_MODEL_LIST: z.string().optional(),
|
|
23
24
|
|
|
24
25
|
ENABLED_DEEPSEEK: z.boolean(),
|
|
25
26
|
DEEPSEEK_API_KEY: z.string().optional(),
|
|
@@ -109,6 +110,7 @@ export const getLLMConfig = () => {
|
|
|
109
110
|
|
|
110
111
|
ENABLED_ZHIPU: !!process.env.ZHIPU_API_KEY,
|
|
111
112
|
ZHIPU_API_KEY: process.env.ZHIPU_API_KEY,
|
|
113
|
+
ZHIPU_MODEL_LIST: process.env.ZHIPU_MODEL_LIST,
|
|
112
114
|
|
|
113
115
|
ENABLED_DEEPSEEK: !!process.env.DEEPSEEK_API_KEY,
|
|
114
116
|
DEEPSEEK_API_KEY: process.env.DEEPSEEK_API_KEY,
|
|
@@ -7,7 +7,7 @@ import { ssoProviders } from './sso-providers';
|
|
|
7
7
|
export const initSSOProviders = () => {
|
|
8
8
|
return authEnv.NEXT_PUBLIC_ENABLE_NEXT_AUTH
|
|
9
9
|
? authEnv.NEXT_AUTH_SSO_PROVIDERS.split(/[,,]/).map((provider) => {
|
|
10
|
-
const validProvider = ssoProviders.find((item) => item.id === provider);
|
|
10
|
+
const validProvider = ssoProviders.find((item) => item.id === provider.trim());
|
|
11
11
|
|
|
12
12
|
if (validProvider) return validProvider.provider;
|
|
13
13
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { OIDCConfig } from '@auth/core/providers';
|
|
2
|
+
|
|
3
|
+
import { authEnv } from '@/config/auth';
|
|
4
|
+
|
|
5
|
+
import { CommonProviderConfig } from './sso.config';
|
|
6
|
+
|
|
7
|
+
export type CloudflareZeroTrustProfile = {
|
|
8
|
+
email: string;
|
|
9
|
+
name: string;
|
|
10
|
+
sub: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const provider = {
|
|
14
|
+
id: 'cloudflare-zero-trust',
|
|
15
|
+
provider: {
|
|
16
|
+
...CommonProviderConfig,
|
|
17
|
+
authorization: { params: { scope: 'openid email profile' } },
|
|
18
|
+
checks: ['state', 'pkce'],
|
|
19
|
+
clientId: authEnv.CLOUDFLARE_ZERO_TRUST_CLIENT_ID,
|
|
20
|
+
clientSecret: authEnv.CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET,
|
|
21
|
+
id: 'cloudflare-zero-trust',
|
|
22
|
+
issuer: authEnv.CLOUDFLARE_ZERO_TRUST_ISSUER,
|
|
23
|
+
name: 'Cloudflare Zero Trust',
|
|
24
|
+
profile(profile) {
|
|
25
|
+
return {
|
|
26
|
+
email: profile.email,
|
|
27
|
+
name: profile.name,
|
|
28
|
+
providerAccountId: profile.sub,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
type: 'oidc',
|
|
32
|
+
} satisfies OIDCConfig<CloudflareZeroTrustProfile>,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default provider;
|
|
@@ -2,7 +2,9 @@ import Auth0 from './auth0';
|
|
|
2
2
|
import Authelia from './authelia';
|
|
3
3
|
import Authentik from './authentik';
|
|
4
4
|
import AzureAD from './azure-ad';
|
|
5
|
+
import CloudflareZeroTrust from './cloudflare-zero-trust';
|
|
5
6
|
import Github from './github';
|
|
7
|
+
import Logto from './logto';
|
|
6
8
|
import Zitadel from './zitadel';
|
|
7
9
|
|
|
8
|
-
export const ssoProviders = [Auth0, Authentik, AzureAD, Github, Zitadel, Authelia];
|
|
10
|
+
export const ssoProviders = [Auth0, Authentik, AzureAD, Github, Zitadel, Authelia, Logto, CloudflareZeroTrust];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { OIDCConfig, OIDCUserConfig } from '@auth/core/providers';
|
|
2
|
+
|
|
3
|
+
import { authEnv } from '@/config/auth';
|
|
4
|
+
|
|
5
|
+
import { CommonProviderConfig } from './sso.config';
|
|
6
|
+
|
|
7
|
+
interface LogtoProfile extends Record<string, any> {
|
|
8
|
+
email: string;
|
|
9
|
+
id: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
picture: string;
|
|
12
|
+
sub: string;
|
|
13
|
+
username: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function LobeLogtoProvider(config: OIDCUserConfig<LogtoProfile>): OIDCConfig<LogtoProfile> {
|
|
17
|
+
return {
|
|
18
|
+
...CommonProviderConfig,
|
|
19
|
+
...config,
|
|
20
|
+
id: 'logto',
|
|
21
|
+
name: 'Logto',
|
|
22
|
+
profile(profile) {
|
|
23
|
+
// You can customize the user profile mapping here
|
|
24
|
+
return {
|
|
25
|
+
email: profile.email,
|
|
26
|
+
id: profile.sub,
|
|
27
|
+
image: profile.picture,
|
|
28
|
+
name: profile.name ?? profile.username,
|
|
29
|
+
providerAccountId: profile.sub,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
type: 'oidc',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const provider = {
|
|
37
|
+
id: 'logto',
|
|
38
|
+
provider: LobeLogtoProvider({
|
|
39
|
+
authorization: {
|
|
40
|
+
params: { scope: 'openid offline_access profile email' },
|
|
41
|
+
},
|
|
42
|
+
// You can get the issuer value from the Logto Application Details page,
|
|
43
|
+
// in the field "Issuer endpoint"
|
|
44
|
+
clientId: authEnv.LOGTO_CLIENT_ID,
|
|
45
|
+
clientSecret: authEnv.LOGTO_CLIENT_SECRET,
|
|
46
|
+
issuer: authEnv.LOGTO_ISSUER,
|
|
47
|
+
}),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default provider;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
OpenRouterProviderCard,
|
|
10
10
|
SiliconCloudProviderCard,
|
|
11
11
|
TogetherAIProviderCard,
|
|
12
|
+
ZhiPuProviderCard,
|
|
12
13
|
} from '@/config/modelProviders';
|
|
13
14
|
import { enableNextAuth } from '@/const/auth';
|
|
14
15
|
import { parseSystemAgent } from '@/server/globalConfig/parseSystemAgent';
|
|
@@ -26,6 +27,8 @@ export const getServerGlobalConfig = () => {
|
|
|
26
27
|
|
|
27
28
|
ENABLED_MOONSHOT,
|
|
28
29
|
ENABLED_ZHIPU,
|
|
30
|
+
ZHIPU_MODEL_LIST,
|
|
31
|
+
|
|
29
32
|
ENABLED_AWS_BEDROCK,
|
|
30
33
|
ENABLED_GOOGLE,
|
|
31
34
|
ENABLED_GROQ,
|
|
@@ -136,7 +139,14 @@ export const getServerGlobalConfig = () => {
|
|
|
136
139
|
}),
|
|
137
140
|
},
|
|
138
141
|
zeroone: { enabled: ENABLED_ZEROONE },
|
|
139
|
-
zhipu: {
|
|
142
|
+
zhipu: {
|
|
143
|
+
enabled: ENABLED_ZHIPU,
|
|
144
|
+
enabledModels: extractEnabledModels(ZHIPU_MODEL_LIST),
|
|
145
|
+
serverModelCards: transformToChatModelCards({
|
|
146
|
+
defaultChatModels: ZhiPuProviderCard.chatModels,
|
|
147
|
+
modelString: ZHIPU_MODEL_LIST
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
140
150
|
},
|
|
141
151
|
oAuthSSOProviders: authEnv.NEXT_AUTH_SSO_PROVIDERS.trim().split(/[,,]/),
|
|
142
152
|
systemAgent: parseSystemAgent(appEnv.SYSTEM_AGENT),
|