@lobehub/lobehub 2.0.0-next.355 → 2.0.0-next.357
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/.env.desktop +0 -1
- package/.env.example +16 -20
- package/.env.example.development +1 -4
- package/.github/workflows/e2e.yml +10 -11
- package/CHANGELOG.md +60 -0
- package/Dockerfile +28 -4
- package/changelog/v1.json +18 -0
- package/docker-compose/local/docker-compose.yml +2 -2
- package/docker-compose/local/grafana/docker-compose.yml +2 -2
- package/docker-compose/local/logto/docker-compose.yml +2 -2
- package/docker-compose/local/zitadel/.env.example +2 -2
- package/docker-compose/local/zitadel/.env.zh-CN.example +2 -2
- package/docker-compose/production/grafana/docker-compose.yml +2 -2
- package/docker-compose/production/logto/.env.example +2 -2
- package/docker-compose/production/logto/.env.zh-CN.example +2 -2
- package/docker-compose/production/zitadel/.env.example +2 -2
- package/docker-compose/production/zitadel/.env.zh-CN.example +2 -2
- package/docs/development/basic/add-new-authentication-providers.mdx +144 -136
- package/docs/development/basic/add-new-authentication-providers.zh-CN.mdx +146 -136
- package/docs/self-hosting/advanced/auth/legacy.mdx +4 -0
- package/docs/self-hosting/advanced/auth/legacy.zh-CN.mdx +4 -0
- package/docs/self-hosting/advanced/auth/nextauth-to-betterauth.mdx +326 -0
- package/docs/self-hosting/advanced/auth/nextauth-to-betterauth.zh-CN.mdx +323 -0
- package/docs/self-hosting/advanced/auth.mdx +43 -16
- package/docs/self-hosting/advanced/auth.zh-CN.mdx +44 -16
- package/docs/self-hosting/advanced/redis/upstash.mdx +69 -0
- package/docs/self-hosting/advanced/redis/upstash.zh-CN.mdx +69 -0
- package/docs/self-hosting/advanced/redis.mdx +128 -0
- package/docs/self-hosting/advanced/redis.zh-CN.mdx +126 -0
- package/docs/self-hosting/environment-variables/auth.mdx +15 -1
- package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +15 -1
- package/docs/self-hosting/environment-variables/basic.mdx +13 -0
- package/docs/self-hosting/environment-variables/basic.zh-CN.mdx +13 -0
- package/docs/self-hosting/environment-variables/redis.mdx +68 -0
- package/docs/self-hosting/environment-variables/redis.zh-CN.mdx +67 -0
- package/docs/self-hosting/migration/v2/breaking-changes.mdx +23 -23
- package/docs/self-hosting/migration/v2/breaking-changes.zh-CN.mdx +23 -23
- package/docs/self-hosting/server-database/docker-compose.mdx +4 -4
- package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +4 -4
- package/e2e/CLAUDE.md +5 -6
- package/e2e/docs/local-setup.md +9 -12
- package/e2e/scripts/setup.ts +9 -15
- package/e2e/src/support/webServer.ts +6 -5
- package/package.json +4 -6
- package/packages/database/src/schemas/nextauth.ts +7 -2
- package/packages/model-runtime/src/core/contextBuilders/anthropic.test.ts +370 -0
- package/packages/model-runtime/src/core/contextBuilders/anthropic.ts +18 -5
- package/packages/utils/src/server/__tests__/auth.test.ts +1 -63
- package/packages/utils/src/server/auth.ts +8 -24
- package/scripts/_shared/checkDeprecatedAuth.js +99 -0
- package/scripts/clerk-to-betterauth/index.ts +8 -3
- package/scripts/nextauth-to-betterauth/_internal/config.ts +41 -0
- package/scripts/nextauth-to-betterauth/_internal/db.ts +32 -0
- package/scripts/nextauth-to-betterauth/_internal/env.ts +6 -0
- package/scripts/nextauth-to-betterauth/index.ts +226 -0
- package/scripts/nextauth-to-betterauth/verify.ts +188 -0
- package/scripts/prebuild.mts +66 -13
- package/scripts/serverLauncher/startServer.js +5 -5
- package/src/app/(backend)/api/auth/[...all]/route.ts +5 -23
- package/src/app/(backend)/api/webhooks/casdoor/route.ts +5 -5
- package/src/app/(backend)/api/webhooks/logto/route.ts +8 -8
- package/src/app/(backend)/middleware/auth/index.test.ts +8 -1
- package/src/app/(backend)/middleware/auth/index.ts +6 -15
- package/src/app/(backend)/middleware/auth/utils.test.ts +0 -32
- package/src/app/(backend)/middleware/auth/utils.ts +3 -8
- package/src/app/(backend)/webapi/chat/[provider]/route.test.ts +8 -1
- package/src/app/(backend)/webapi/create-image/comfyui/route.ts +0 -1
- package/src/app/(backend)/webapi/models/[provider]/route.test.ts +8 -1
- package/src/app/[variants]/(auth)/signin/SignInEmailStep.tsx +1 -1
- package/src/app/[variants]/(auth)/signup/[[...signup]]/page.tsx +4 -17
- package/src/app/[variants]/(main)/agent/cron/[cronId]/features/CronJobContentEditor.tsx +34 -21
- package/src/app/[variants]/(main)/settings/profile/features/SSOProvidersList/index.tsx +12 -19
- package/src/app/[variants]/(main)/settings/profile/index.tsx +8 -14
- package/src/components/{NextAuth/AuthIcons.tsx → AuthIcons.tsx} +8 -10
- package/src/envs/auth.ts +12 -51
- package/src/envs/email.ts +3 -0
- package/src/envs/redis.ts +12 -54
- package/src/features/ChatInput/ChatInputProvider.tsx +22 -2
- package/src/features/ChatInput/InputEditor/index.tsx +14 -3
- package/src/features/ChatInput/store/initialState.ts +2 -0
- package/src/features/EditorCanvas/DiffAllToolbar.tsx +4 -5
- package/src/features/EditorCanvas/DocumentIdMode.tsx +21 -1
- package/src/features/User/__tests__/PanelContent.test.tsx +0 -11
- package/src/features/User/__tests__/UserAvatar.test.tsx +1 -16
- package/src/layout/AuthProvider/index.tsx +1 -6
- package/src/layout/GlobalProvider/StoreInitialization.tsx +2 -4
- package/src/libs/better-auth/define-config.ts +2 -0
- package/src/libs/better-auth/plugins/email-whitelist.test.ts +120 -0
- package/src/libs/better-auth/plugins/email-whitelist.ts +62 -0
- package/src/libs/next/config/define-config.ts +13 -1
- package/src/libs/next/proxy/define-config.ts +2 -75
- package/src/libs/oidc-provider/provider.test.ts +0 -4
- package/src/libs/redis/index.ts +0 -1
- package/src/libs/redis/manager.test.ts +9 -45
- package/src/libs/redis/manager.ts +2 -16
- package/src/libs/redis/redis.test.ts +2 -4
- package/src/libs/redis/redis.ts +2 -4
- package/src/libs/redis/types.ts +2 -24
- package/src/libs/redis/utils.test.ts +0 -10
- package/src/libs/redis/utils.ts +0 -19
- package/src/libs/trpc/lambda/context.test.ts +0 -13
- package/src/libs/trpc/lambda/context.ts +21 -59
- package/src/libs/trpc/middleware/userAuth.ts +1 -7
- package/src/libs/trusted-client/getSessionUser.ts +15 -35
- package/src/server/globalConfig/index.ts +1 -3
- package/src/server/routers/lambda/__tests__/user.test.ts +0 -48
- package/src/server/routers/lambda/user.ts +1 -12
- package/src/server/services/email/impls/nodemailer/index.ts +2 -2
- package/src/server/services/webhookUser/index.ts +88 -0
- package/src/services/user/index.test.ts +0 -14
- package/src/services/user/index.ts +0 -4
- package/src/store/document/slices/document/action.ts +1 -0
- package/src/store/user/slices/auth/action.test.ts +22 -126
- package/src/store/user/slices/auth/action.ts +32 -65
- package/src/store/user/slices/auth/initialState.ts +0 -3
- package/src/store/user/slices/auth/selectors.ts +0 -3
- package/tests/setup.ts +10 -0
- package/scripts/_shared/checkDeprecatedClerkEnv.js +0 -42
- package/src/app/(backend)/api/auth/adapter/route.ts +0 -137
- package/src/app/[variants]/(auth)/next-auth/error/AuthErrorPage.tsx +0 -40
- package/src/app/[variants]/(auth)/next-auth/error/page.tsx +0 -11
- package/src/app/[variants]/(auth)/next-auth/signin/AuthSignInBox.tsx +0 -167
- package/src/app/[variants]/(auth)/next-auth/signin/page.tsx +0 -11
- package/src/app/[variants]/(auth)/reset-password/layout.tsx +0 -12
- package/src/app/[variants]/(auth)/signin/layout.tsx +0 -12
- package/src/app/[variants]/(auth)/verify-email/layout.tsx +0 -12
- package/src/envs/auth.test.ts +0 -47
- package/src/layout/AuthProvider/NextAuth/UserUpdater.tsx +0 -44
- package/src/layout/AuthProvider/NextAuth/index.tsx +0 -17
- package/src/libs/next-auth/adapter/index.ts +0 -177
- package/src/libs/next-auth/auth.config.ts +0 -64
- package/src/libs/next-auth/index.ts +0 -20
- package/src/libs/next-auth/sso-providers/auth0.ts +0 -24
- package/src/libs/next-auth/sso-providers/authelia.ts +0 -39
- package/src/libs/next-auth/sso-providers/authentik.ts +0 -25
- package/src/libs/next-auth/sso-providers/casdoor.ts +0 -50
- package/src/libs/next-auth/sso-providers/cloudflare-zero-trust.ts +0 -34
- package/src/libs/next-auth/sso-providers/cognito.ts +0 -8
- package/src/libs/next-auth/sso-providers/feishu.ts +0 -83
- package/src/libs/next-auth/sso-providers/generic-oidc.ts +0 -38
- package/src/libs/next-auth/sso-providers/github.ts +0 -23
- package/src/libs/next-auth/sso-providers/google.ts +0 -18
- package/src/libs/next-auth/sso-providers/index.ts +0 -35
- package/src/libs/next-auth/sso-providers/keycloak.ts +0 -22
- package/src/libs/next-auth/sso-providers/logto.ts +0 -48
- package/src/libs/next-auth/sso-providers/microsoft-entra-id-helper.ts +0 -29
- package/src/libs/next-auth/sso-providers/microsoft-entra-id.ts +0 -19
- package/src/libs/next-auth/sso-providers/okta.ts +0 -22
- package/src/libs/next-auth/sso-providers/sso.config.ts +0 -8
- package/src/libs/next-auth/sso-providers/wechat.ts +0 -36
- package/src/libs/next-auth/sso-providers/zitadel.ts +0 -21
- package/src/libs/redis/upstash.test.ts +0 -158
- package/src/libs/redis/upstash.ts +0 -136
- package/src/server/services/nextAuthUser/index.ts +0 -318
- package/src/server/services/nextAuthUser/utils.ts +0 -62
- package/src/types/next-auth.d.ts +0 -26
|
@@ -16,6 +16,19 @@ LobeChat 在部署时提供了一些额外的配置项,你可以使用环境
|
|
|
16
16
|
|
|
17
17
|
## 通用变量
|
|
18
18
|
|
|
19
|
+
### `KEY_VAULTS_SECRET`
|
|
20
|
+
|
|
21
|
+
- 类型:必选(服务端数据库模式)
|
|
22
|
+
- 描述:用于加密用户存储在数据库中的敏感信息(如 API Key、baseURL 等),防止数据库泄露时关键信息被暴露
|
|
23
|
+
- 默认值:-
|
|
24
|
+
- 示例:`Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ=`
|
|
25
|
+
|
|
26
|
+
<Callout type={'warning'}>
|
|
27
|
+
此密钥用于加密敏感数据,一旦设置后请勿更改,否则已加密的数据将无法解密。
|
|
28
|
+
</Callout>
|
|
29
|
+
|
|
30
|
+
<GenerateSecret envName="KEY_VAULTS_SECRET" />
|
|
31
|
+
|
|
19
32
|
### `API_KEY_SELECT_MODE`
|
|
20
33
|
|
|
21
34
|
- 类型:可选
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configure Redis Cache Service
|
|
3
|
+
description: Learn how to configure Redis cache service to optimize performance and session management.
|
|
4
|
+
tags:
|
|
5
|
+
- Redis
|
|
6
|
+
- Cache
|
|
7
|
+
- Session Storage
|
|
8
|
+
- Environment Variables
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Configure Redis Cache Service
|
|
12
|
+
|
|
13
|
+
LobeChat uses Redis as a high-performance cache and session storage service. Configuring Redis can optimize authentication session management, file proxy caching, and more.
|
|
14
|
+
|
|
15
|
+
## Core Environment Variables
|
|
16
|
+
|
|
17
|
+
### `REDIS_URL`
|
|
18
|
+
|
|
19
|
+
- Type: Optional
|
|
20
|
+
- Description: Redis server connection URL
|
|
21
|
+
- Default: -
|
|
22
|
+
- Example: `redis://localhost:6379`
|
|
23
|
+
|
|
24
|
+
Supported URL formats:
|
|
25
|
+
|
|
26
|
+
- Standard: `redis://localhost:6379`
|
|
27
|
+
- With authentication: `redis://username:password@localhost:6379`
|
|
28
|
+
- With database: `redis://localhost:6379/0`
|
|
29
|
+
|
|
30
|
+
### `REDIS_PREFIX`
|
|
31
|
+
|
|
32
|
+
- Type: Optional
|
|
33
|
+
- Description: Prefix for Redis keys, used to isolate data in a shared Redis instance
|
|
34
|
+
- Default: `lobechat`
|
|
35
|
+
- Example: `my-lobechat`
|
|
36
|
+
|
|
37
|
+
### `REDIS_TLS`
|
|
38
|
+
|
|
39
|
+
- Type: Optional
|
|
40
|
+
- Description: Whether to enable TLS/SSL encrypted connection
|
|
41
|
+
- Default: `false`
|
|
42
|
+
- Example: `true`
|
|
43
|
+
|
|
44
|
+
<Callout type={'tip'}>
|
|
45
|
+
Redis services from cloud providers usually require TLS enabled to ensure secure data
|
|
46
|
+
transmission.
|
|
47
|
+
</Callout>
|
|
48
|
+
|
|
49
|
+
### `REDIS_PASSWORD`
|
|
50
|
+
|
|
51
|
+
- Type: Optional
|
|
52
|
+
- Description: Redis authentication password
|
|
53
|
+
- Default: -
|
|
54
|
+
- Example: `your-password`
|
|
55
|
+
|
|
56
|
+
### `REDIS_USERNAME`
|
|
57
|
+
|
|
58
|
+
- Type: Optional
|
|
59
|
+
- Description: Redis authentication username (Redis 6.0+ ACL authentication)
|
|
60
|
+
- Default: -
|
|
61
|
+
- Example: `default`
|
|
62
|
+
|
|
63
|
+
### `REDIS_DATABASE`
|
|
64
|
+
|
|
65
|
+
- Type: Optional
|
|
66
|
+
- Description: Redis database index (0-15)
|
|
67
|
+
- Default: `0`
|
|
68
|
+
- Example: `1`
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 配置 Redis 缓存服务
|
|
3
|
+
description: 了解如何配置 Redis 缓存服务以优化性能和会话管理。
|
|
4
|
+
tags:
|
|
5
|
+
- Redis
|
|
6
|
+
- 缓存
|
|
7
|
+
- 会话存储
|
|
8
|
+
- 环境变量
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# 配置 Redis 缓存服务
|
|
12
|
+
|
|
13
|
+
LobeChat 使用 Redis 作为高性能缓存和会话存储服务。配置 Redis 可以优化认证会话管理、文件代理缓存等功能。
|
|
14
|
+
|
|
15
|
+
## 核心环境变量
|
|
16
|
+
|
|
17
|
+
### `REDIS_URL`
|
|
18
|
+
|
|
19
|
+
- 类型:可选
|
|
20
|
+
- 描述:Redis 服务器的连接 URL
|
|
21
|
+
- 默认值:-
|
|
22
|
+
- 示例:`redis://localhost:6379`
|
|
23
|
+
|
|
24
|
+
支持的 URL 格式:
|
|
25
|
+
|
|
26
|
+
- 标准格式:`redis://localhost:6379`
|
|
27
|
+
- 带认证:`redis://username:password@localhost:6379`
|
|
28
|
+
- 带数据库:`redis://localhost:6379/0`
|
|
29
|
+
|
|
30
|
+
### `REDIS_PREFIX`
|
|
31
|
+
|
|
32
|
+
- 类型:可选
|
|
33
|
+
- 描述:Redis 键的前缀,用于在共享 Redis 实例中隔离数据
|
|
34
|
+
- 默认值:`lobechat`
|
|
35
|
+
- 示例:`my-lobechat`
|
|
36
|
+
|
|
37
|
+
### `REDIS_TLS`
|
|
38
|
+
|
|
39
|
+
- 类型:可选
|
|
40
|
+
- 描述:是否启用 TLS/SSL 加密连接
|
|
41
|
+
- 默认值:`false`
|
|
42
|
+
- 示例:`true`
|
|
43
|
+
|
|
44
|
+
<Callout type={'tip'}>
|
|
45
|
+
云服务商提供的 Redis 服务通常需要启用 TLS 以确保数据传输安全。
|
|
46
|
+
</Callout>
|
|
47
|
+
|
|
48
|
+
### `REDIS_PASSWORD`
|
|
49
|
+
|
|
50
|
+
- 类型:可选
|
|
51
|
+
- 描述:Redis 认证密码
|
|
52
|
+
- 默认值:-
|
|
53
|
+
- 示例:`your-password`
|
|
54
|
+
|
|
55
|
+
### `REDIS_USERNAME`
|
|
56
|
+
|
|
57
|
+
- 类型:可选
|
|
58
|
+
- 描述:Redis 认证用户名(Redis 6.0+ ACL 认证)
|
|
59
|
+
- 默认值:-
|
|
60
|
+
- 示例:`default`
|
|
61
|
+
|
|
62
|
+
### `REDIS_DATABASE`
|
|
63
|
+
|
|
64
|
+
- 类型:可选
|
|
65
|
+
- 描述:Redis 数据库索引(0-15)
|
|
66
|
+
- 默认值:`0`
|
|
67
|
+
- 示例:`1`
|
|
@@ -18,18 +18,18 @@ This document outlines the breaking changes introduced in LobeHub 2.0 and provid
|
|
|
18
18
|
|
|
19
19
|
The following environment variables have been removed in LobeHub 2.0:
|
|
20
20
|
|
|
21
|
-
| Environment Variable | Removal Reason
|
|
22
|
-
| ----------------------------------- |
|
|
23
|
-
| `ACCESS_CODE` | No longer supported, use Better Auth authentication system
|
|
24
|
-
| `NEXT_PUBLIC_SERVICE_MODE` | 2.0 only supports Server DB mode, Client DB (PGlite) removed
|
|
25
|
-
| `NEXT_PUBLIC_ENABLE_BETTER_AUTH` | Automatically detected via `AUTH_SECRET` presence
|
|
26
|
-
| `NEXT_PUBLIC_AUTH_URL` / `AUTH_URL` | Automatically detected from request headers
|
|
27
|
-
| `NEXT_PUBLIC_ENABLE_NEXT_AUTH` | NextAuth removed
|
|
28
|
-
| `NEXT_AUTH_SECRET` | NextAuth removed
|
|
29
|
-
| `NEXT_AUTH_SSO_PROVIDERS` | NextAuth removed
|
|
30
|
-
| `NEXTAUTH_URL` | NextAuth removed
|
|
31
|
-
| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | Clerk removed
|
|
32
|
-
| `CLERK_SECRET_KEY` | Clerk removed
|
|
21
|
+
| Environment Variable | Removal Reason |
|
|
22
|
+
| ----------------------------------- | ------------------------------------------------------------ |
|
|
23
|
+
| `ACCESS_CODE` | No longer supported, use Better Auth authentication system |
|
|
24
|
+
| `NEXT_PUBLIC_SERVICE_MODE` | 2.0 only supports Server DB mode, Client DB (PGlite) removed |
|
|
25
|
+
| `NEXT_PUBLIC_ENABLE_BETTER_AUTH` | Automatically detected via `AUTH_SECRET` presence |
|
|
26
|
+
| `NEXT_PUBLIC_AUTH_URL` / `AUTH_URL` | Automatically detected from request headers |
|
|
27
|
+
| `NEXT_PUBLIC_ENABLE_NEXT_AUTH` | NextAuth removed |
|
|
28
|
+
| `NEXT_AUTH_SECRET` | NextAuth removed |
|
|
29
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | NextAuth removed |
|
|
30
|
+
| `NEXTAUTH_URL` | NextAuth removed |
|
|
31
|
+
| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | Clerk removed |
|
|
32
|
+
| `CLERK_SECRET_KEY` | Clerk removed |
|
|
33
33
|
|
|
34
34
|
## New Required Environment Variables
|
|
35
35
|
|
|
@@ -40,15 +40,15 @@ LobeHub 2.0 only supports Better Auth authentication system. The following envir
|
|
|
40
40
|
|
|
41
41
|
## New Optional Environment Variables
|
|
42
42
|
|
|
43
|
-
| Environment Variable
|
|
44
|
-
|
|
|
45
|
-
| `AUTH_SSO_PROVIDERS`
|
|
46
|
-
| `INTERNAL_JWT_EXPIRATION`
|
|
47
|
-
| `
|
|
48
|
-
| `SMTP_HOST`
|
|
49
|
-
| `SMTP_PORT`
|
|
50
|
-
| `SMTP_USER`
|
|
51
|
-
| `SMTP_PASS`
|
|
43
|
+
| Environment Variable | Description |
|
|
44
|
+
| ------------------------- | --------------------------------------------------- |
|
|
45
|
+
| `AUTH_SSO_PROVIDERS` | Comma-separated list of enabled SSO providers |
|
|
46
|
+
| `INTERNAL_JWT_EXPIRATION` | Internal JWT token expiration time (default: `30s`) |
|
|
47
|
+
| `AUTH_EMAIL_VERIFICATION` | Set to `1` to require email verification |
|
|
48
|
+
| `SMTP_HOST` | SMTP server hostname for email features |
|
|
49
|
+
| `SMTP_PORT` | SMTP server port |
|
|
50
|
+
| `SMTP_USER` | SMTP authentication username |
|
|
51
|
+
| `SMTP_PASS` | SMTP authentication password |
|
|
52
52
|
|
|
53
53
|
For detailed configuration, see [Authentication Environment Variables](/docs/self-hosting/environment-variables/auth).
|
|
54
54
|
|
|
@@ -60,11 +60,11 @@ LobeHub 2.0 only supports Better Auth authentication system. NextAuth and Clerk
|
|
|
60
60
|
|
|
61
61
|
### Migrating from NextAuth
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
See the [NextAuth Migration Guide](/docs/self-hosting/advanced/auth/nextauth-to-betterauth).
|
|
64
64
|
|
|
65
65
|
### Migrating from Clerk
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
See the [Clerk Migration Guide](/docs/self-hosting/advanced/auth/clerk-to-betterauth).
|
|
68
68
|
|
|
69
69
|
## Database Mode Changes
|
|
70
70
|
|
|
@@ -16,18 +16,18 @@ tags:
|
|
|
16
16
|
|
|
17
17
|
以下环境变量在 LobeHub 2.0 中已被移除:
|
|
18
18
|
|
|
19
|
-
| 环境变量
|
|
20
|
-
| ----------------------------------- |
|
|
21
|
-
| `ACCESS_CODE` | 不再支持,请使用 Better Auth 认证系统
|
|
22
|
-
| `NEXT_PUBLIC_SERVICE_MODE` | 2.0 仅支持 Server DB 模式,不再支持 Client DB (PGlite)
|
|
23
|
-
| `NEXT_PUBLIC_ENABLE_BETTER_AUTH` | 通过 `AUTH_SECRET` 是否存在自动检测
|
|
24
|
-
| `NEXT_PUBLIC_AUTH_URL` / `AUTH_URL` | 从请求头中自动检测
|
|
25
|
-
| `NEXT_PUBLIC_ENABLE_NEXT_AUTH` | NextAuth 已移除
|
|
26
|
-
| `NEXT_AUTH_SECRET` | NextAuth 已移除
|
|
27
|
-
| `NEXT_AUTH_SSO_PROVIDERS` | NextAuth 已移除
|
|
28
|
-
| `NEXTAUTH_URL` | NextAuth 已移除
|
|
29
|
-
| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | Clerk 已移除
|
|
30
|
-
| `CLERK_SECRET_KEY` | Clerk 已移除
|
|
19
|
+
| 环境变量 | 移除原因 |
|
|
20
|
+
| ----------------------------------- | -------------------------------------------- |
|
|
21
|
+
| `ACCESS_CODE` | 不再支持,请使用 Better Auth 认证系统 |
|
|
22
|
+
| `NEXT_PUBLIC_SERVICE_MODE` | 2.0 仅支持 Server DB 模式,不再支持 Client DB (PGlite) |
|
|
23
|
+
| `NEXT_PUBLIC_ENABLE_BETTER_AUTH` | 通过 `AUTH_SECRET` 是否存在自动检测 |
|
|
24
|
+
| `NEXT_PUBLIC_AUTH_URL` / `AUTH_URL` | 从请求头中自动检测 |
|
|
25
|
+
| `NEXT_PUBLIC_ENABLE_NEXT_AUTH` | NextAuth 已移除 |
|
|
26
|
+
| `NEXT_AUTH_SECRET` | NextAuth 已移除 |
|
|
27
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | NextAuth 已移除 |
|
|
28
|
+
| `NEXTAUTH_URL` | NextAuth 已移除 |
|
|
29
|
+
| `NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY` | Clerk 已移除 |
|
|
30
|
+
| `CLERK_SECRET_KEY` | Clerk 已移除 |
|
|
31
31
|
|
|
32
32
|
## 新增的必需环境变量
|
|
33
33
|
|
|
@@ -38,15 +38,15 @@ LobeHub 2.0 仅支持 Better Auth 认证系统。以下环境变量现在是必
|
|
|
38
38
|
|
|
39
39
|
## 新增的可选环境变量
|
|
40
40
|
|
|
41
|
-
| 环境变量
|
|
42
|
-
|
|
|
43
|
-
| `AUTH_SSO_PROVIDERS`
|
|
44
|
-
| `INTERNAL_JWT_EXPIRATION`
|
|
45
|
-
| `
|
|
46
|
-
| `SMTP_HOST`
|
|
47
|
-
| `SMTP_PORT`
|
|
48
|
-
| `SMTP_USER`
|
|
49
|
-
| `SMTP_PASS`
|
|
41
|
+
| 环境变量 | 说明 |
|
|
42
|
+
| ------------------------- | ----------------------- |
|
|
43
|
+
| `AUTH_SSO_PROVIDERS` | 启用的 SSO 提供商列表,以逗号分隔 |
|
|
44
|
+
| `INTERNAL_JWT_EXPIRATION` | 内部 JWT 令牌过期时间(默认:`30s`) |
|
|
45
|
+
| `AUTH_EMAIL_VERIFICATION` | 设置为 `1` 以要求邮箱验证 |
|
|
46
|
+
| `SMTP_HOST` | 邮件功能的 SMTP 服务器主机名 |
|
|
47
|
+
| `SMTP_PORT` | SMTP 服务器端口 |
|
|
48
|
+
| `SMTP_USER` | SMTP 认证用户名 |
|
|
49
|
+
| `SMTP_PASS` | SMTP 认证密码 |
|
|
50
50
|
|
|
51
51
|
详细配置请参阅[身份验证环境变量](/docs/self-hosting/environment-variables/auth)。
|
|
52
52
|
|
|
@@ -58,11 +58,11 @@ LobeHub 2.0 仅支持 Better Auth 认证系统,不再支持 NextAuth 和 Clerk
|
|
|
58
58
|
|
|
59
59
|
### 从 NextAuth 迁移
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
请参阅 [NextAuth 迁移指南](/zh/docs/self-hosting/advanced/auth/nextauth-to-betterauth)。
|
|
62
62
|
|
|
63
63
|
### 从 Clerk 迁移
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
请参阅 [Clerk 迁移指南](/zh/docs/self-hosting/advanced/auth/clerk-to-betterauth)。
|
|
66
66
|
|
|
67
67
|
## 数据库模式变更
|
|
68
68
|
|
|
@@ -562,9 +562,9 @@ Next, modify the configuration files to achieve domain release.
|
|
|
562
562
|
# - 'APP_URL=http://localhost:3210'
|
|
563
563
|
- 'APP_URL=https://lobe.example.com'
|
|
564
564
|
|
|
565
|
-
- '
|
|
565
|
+
- 'AUTH_SSO_PROVIDERS=casdoor'
|
|
566
566
|
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
|
|
567
|
-
- '
|
|
567
|
+
- 'AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
|
|
568
568
|
# - 'AUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
|
|
569
569
|
- 'AUTH_URL=https://lobe.example.com/api/auth'
|
|
570
570
|
|
|
@@ -837,9 +837,9 @@ services:
|
|
|
837
837
|
# - 'APP_URL=http://localhost:3210'
|
|
838
838
|
- 'APP_URL=https://lobe.example.com'
|
|
839
839
|
|
|
840
|
-
- '
|
|
840
|
+
- 'AUTH_SSO_PROVIDERS=casdoor'
|
|
841
841
|
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
|
|
842
|
-
- '
|
|
842
|
+
- 'AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
|
|
843
843
|
# - 'AUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
|
|
844
844
|
- 'AUTH_URL=https://lobe.example.com/api/auth'
|
|
845
845
|
|
|
@@ -538,9 +538,9 @@ docker compose up -d
|
|
|
538
538
|
# - 'APP_URL=http://localhost:3210'
|
|
539
539
|
- 'APP_URL=https://lobe.example.com'
|
|
540
540
|
|
|
541
|
-
- '
|
|
541
|
+
- 'AUTH_SSO_PROVIDERS=casdoor'
|
|
542
542
|
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
|
|
543
|
-
- '
|
|
543
|
+
- 'AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
|
|
544
544
|
# - 'AUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
|
|
545
545
|
- 'AUTH_URL=https://lobe.example.com/api/auth'
|
|
546
546
|
|
|
@@ -812,9 +812,9 @@ services:
|
|
|
812
812
|
# - 'APP_URL=http://localhost:3210'
|
|
813
813
|
- 'APP_URL=https://lobe.example.com'
|
|
814
814
|
|
|
815
|
-
- '
|
|
815
|
+
- 'AUTH_SSO_PROVIDERS=casdoor'
|
|
816
816
|
- 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
|
|
817
|
-
- '
|
|
817
|
+
- 'AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
|
|
818
818
|
# - 'AUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
|
|
819
819
|
- 'AUTH_URL=https://lobe.example.com/api/auth'
|
|
820
820
|
|
package/e2e/CLAUDE.md
CHANGED
|
@@ -298,12 +298,11 @@ HEADLESS=false pnpm exec cucumber-js --config cucumber.config.js --tags "@smoke"
|
|
|
298
298
|
运行测试需要以下环境变量:
|
|
299
299
|
|
|
300
300
|
```bash
|
|
301
|
-
BASE_URL=http://localhost:3010
|
|
302
|
-
DATABASE_URL=postgresql://...
|
|
303
|
-
DATABASE_DRIVER=node
|
|
304
|
-
KEY_VAULTS_SECRET=...
|
|
305
|
-
|
|
306
|
-
NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 # 启用 Better Auth
|
|
301
|
+
BASE_URL=http://localhost:3010 # 测试服务器地址
|
|
302
|
+
DATABASE_URL=postgresql://... # 数据库连接
|
|
303
|
+
DATABASE_DRIVER=node # 数据库驱动
|
|
304
|
+
KEY_VAULTS_SECRET=... # 密钥
|
|
305
|
+
AUTH_SECRET=... # Auth 密钥
|
|
307
306
|
|
|
308
307
|
# 可选:S3 相关(如果测试涉及文件上传)
|
|
309
308
|
S3_ACCESS_KEY_ID=e2e-mock-access-key
|
package/e2e/docs/local-setup.md
CHANGED
|
@@ -98,8 +98,7 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
|
|
|
98
98
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
|
|
99
99
|
DATABASE_DRIVER=node \
|
|
100
100
|
KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
|
|
101
|
-
|
|
102
|
-
NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
|
|
101
|
+
AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
|
|
103
102
|
SKIP_LINT=1 \
|
|
104
103
|
bun run build
|
|
105
104
|
```
|
|
@@ -112,8 +111,7 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
|
|
|
112
111
|
DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
|
|
113
112
|
DATABASE_DRIVER=node \
|
|
114
113
|
KEY_VAULTS_SECRET=LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s= \
|
|
115
|
-
|
|
116
|
-
NEXT_PUBLIC_ENABLE_BETTER_AUTH=1 \
|
|
114
|
+
AUTH_SECRET=e2e-test-secret-key-for-better-auth-32chars! \
|
|
117
115
|
NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION=0 \
|
|
118
116
|
S3_ACCESS_KEY_ID=e2e-mock-access-key \
|
|
119
117
|
S3_SECRET_ACCESS_KEY=e2e-mock-secret-key \
|
|
@@ -126,14 +124,13 @@ DATABASE_URL=postgresql://postgres:postgres@localhost:5433/postgres \
|
|
|
126
124
|
|
|
127
125
|
### 服务器启动环境变量
|
|
128
126
|
|
|
129
|
-
| 变量 | 值 | 说明
|
|
130
|
-
| ------------------------------------- | -------------------------------------------------------- |
|
|
131
|
-
| `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5433/postgres` | 数据库连接
|
|
132
|
-
| `DATABASE_DRIVER` | `node` | 数据库驱动
|
|
133
|
-
| `KEY_VAULTS_SECRET` | `LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=` | 密钥保险库密钥
|
|
134
|
-
| `
|
|
135
|
-
| `
|
|
136
|
-
| `NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION` | `0` | 禁用邮箱验证 |
|
|
127
|
+
| 变量 | 值 | 说明 |
|
|
128
|
+
| ------------------------------------- | -------------------------------------------------------- | -------------- |
|
|
129
|
+
| `DATABASE_URL` | `postgresql://postgres:postgres@localhost:5433/postgres` | 数据库连接 |
|
|
130
|
+
| `DATABASE_DRIVER` | `node` | 数据库驱动 |
|
|
131
|
+
| `KEY_VAULTS_SECRET` | `LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=` | 密钥保险库密钥 |
|
|
132
|
+
| `AUTH_SECRET` | `e2e-test-secret-key-for-better-auth-32chars!` | 认证密钥 |
|
|
133
|
+
| `NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION` | `0` | 禁用邮箱验证 |
|
|
137
134
|
|
|
138
135
|
### S3 Mock 变量(必需)
|
|
139
136
|
|
package/e2e/scripts/setup.ts
CHANGED
|
@@ -31,26 +31,22 @@ const CONFIG = {
|
|
|
31
31
|
defaultPort: 3006,
|
|
32
32
|
dockerImage: 'paradedb/paradedb:latest',
|
|
33
33
|
projectRoot: resolve(__dirname, '../..'),
|
|
34
|
-
|
|
35
34
|
|
|
36
|
-
// S3 Mock (required even if not testing file uploads)
|
|
37
|
-
s3Mock: {
|
|
35
|
+
// S3 Mock (required even if not testing file uploads)
|
|
36
|
+
s3Mock: {
|
|
38
37
|
accessKeyId: 'e2e-mock-access-key',
|
|
39
38
|
bucket: 'e2e-mock-bucket',
|
|
40
39
|
endpoint: 'https://e2e-mock-s3.localhost',
|
|
41
40
|
secretAccessKey: 'e2e-mock-secret-key',
|
|
42
|
-
},
|
|
41
|
+
},
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
// Secrets (for e2e testing only)
|
|
48
|
-
secrets: {
|
|
43
|
+
// 2 minutes
|
|
44
|
+
// Secrets (for e2e testing only)
|
|
45
|
+
secrets: {
|
|
49
46
|
betterAuthSecret: 'e2e-test-secret-key-for-better-auth-32chars!',
|
|
50
47
|
keyVaultsSecret: 'LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=',
|
|
51
48
|
},
|
|
52
49
|
|
|
53
|
-
|
|
54
50
|
serverTimeout: 120_000,
|
|
55
51
|
};
|
|
56
52
|
|
|
@@ -263,11 +259,10 @@ async function buildApp(): Promise<void> {
|
|
|
263
259
|
log('🔨', 'Building application (this may take a few minutes)...');
|
|
264
260
|
|
|
265
261
|
await execAsync('bun', ['run', 'build'], {
|
|
266
|
-
|
|
262
|
+
AUTH_SECRET: CONFIG.secrets.betterAuthSecret,
|
|
267
263
|
DATABASE_DRIVER: CONFIG.databaseDriver,
|
|
268
264
|
DATABASE_URL: CONFIG.databaseUrl,
|
|
269
265
|
KEY_VAULTS_SECRET: CONFIG.secrets.keyVaultsSecret,
|
|
270
|
-
NEXT_PUBLIC_ENABLE_BETTER_AUTH: '1',
|
|
271
266
|
SKIP_LINT: '1',
|
|
272
267
|
});
|
|
273
268
|
|
|
@@ -289,12 +284,11 @@ async function isServerRunning(port: number): Promise<boolean> {
|
|
|
289
284
|
|
|
290
285
|
function getServerEnv(port: number): Record<string, string> {
|
|
291
286
|
return {
|
|
292
|
-
|
|
287
|
+
AUTH_EMAIL_VERIFICATION: '0',
|
|
288
|
+
AUTH_SECRET: CONFIG.secrets.betterAuthSecret,
|
|
293
289
|
DATABASE_DRIVER: CONFIG.databaseDriver,
|
|
294
290
|
DATABASE_URL: CONFIG.databaseUrl,
|
|
295
291
|
KEY_VAULTS_SECRET: CONFIG.secrets.keyVaultsSecret,
|
|
296
|
-
NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION: '0',
|
|
297
|
-
NEXT_PUBLIC_ENABLE_BETTER_AUTH: '1',
|
|
298
292
|
NODE_OPTIONS: '--max-old-space-size=6144',
|
|
299
293
|
PORT: String(port),
|
|
300
294
|
S3_ACCESS_KEY_ID: CONFIG.s3Mock.accessKeyId,
|
|
@@ -135,13 +135,14 @@ export async function startWebServer(options: WebServerOptions): Promise<void> {
|
|
|
135
135
|
...process.env,
|
|
136
136
|
// APP_URL is required for Better Auth to recognize localhost as a trusted origin
|
|
137
137
|
APP_URL: `http://localhost:${port}`,
|
|
138
|
+
|
|
139
|
+
// Disable email verification for e2e
|
|
140
|
+
AUTH_EMAIL_VERIFICATION: '0',
|
|
141
|
+
|
|
138
142
|
// E2E test secret keys
|
|
139
|
-
|
|
143
|
+
AUTH_SECRET: 'e2e-test-secret-key-for-better-auth-32chars!',
|
|
144
|
+
|
|
140
145
|
KEY_VAULTS_SECRET: 'LA7n9k3JdEcbSgml2sxfw+4TV1AzaaFU5+R176aQz4s=',
|
|
141
|
-
// Disable email verification for e2e
|
|
142
|
-
NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION: '0',
|
|
143
|
-
// Enable Better Auth for e2e tests with real authentication
|
|
144
|
-
NEXT_PUBLIC_ENABLE_BETTER_AUTH: '1',
|
|
145
146
|
NODE_OPTIONS: '--max-old-space-size=6144',
|
|
146
147
|
PORT: String(port),
|
|
147
148
|
// Mock S3 env vars to prevent initialization errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/lobehub",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.357",
|
|
4
4
|
"description": "LobeHub - an open-source,comprehensive AI Agent 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",
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"@aws-sdk/s3-request-presigner": "~3.932.0",
|
|
147
147
|
"@azure-rest/ai-inference": "1.0.0-beta.5",
|
|
148
148
|
"@azure/core-auth": "^1.10.1",
|
|
149
|
-
"@better-auth/expo": "1.4.17",
|
|
149
|
+
"@better-auth/expo": "^1.4.17",
|
|
150
150
|
"@better-auth/passkey": "^1.4.17",
|
|
151
151
|
"@cfworker/json-schema": "^4.1.1",
|
|
152
152
|
"@codesandbox/sandpack-react": "^2.20.0",
|
|
@@ -224,7 +224,6 @@
|
|
|
224
224
|
"@trpc/react-query": "^11.8.1",
|
|
225
225
|
"@trpc/server": "^11.8.1",
|
|
226
226
|
"@upstash/qstash": "^2.8.4",
|
|
227
|
-
"@upstash/redis": "^1.35.8",
|
|
228
227
|
"@upstash/workflow": "^0.2.23",
|
|
229
228
|
"@vercel/analytics": "^1.6.1",
|
|
230
229
|
"@vercel/edge-config": "^1.4.3",
|
|
@@ -238,7 +237,7 @@
|
|
|
238
237
|
"antd-style": "4.1.0",
|
|
239
238
|
"async-retry": "^1.3.3",
|
|
240
239
|
"bcryptjs": "^3.0.3",
|
|
241
|
-
"better-auth": "1.4.17",
|
|
240
|
+
"better-auth": "^1.4.17",
|
|
242
241
|
"better-auth-harmony": "^1.2.5",
|
|
243
242
|
"better-call": "^1.2.0",
|
|
244
243
|
"brotli-wasm": "^3.0.1",
|
|
@@ -280,7 +279,6 @@
|
|
|
280
279
|
"motion": "^12.23.26",
|
|
281
280
|
"nanoid": "^5.1.6",
|
|
282
281
|
"next": "^16.1.1",
|
|
283
|
-
"next-auth": "5.0.0-beta.30",
|
|
284
282
|
"next-mdx-remote": "^5.0.0",
|
|
285
283
|
"next-themes": "^0.4.6",
|
|
286
284
|
"nextjs-toploader": "^3.9.17",
|
|
@@ -401,7 +399,7 @@
|
|
|
401
399
|
"@types/unist": "^3.0.3",
|
|
402
400
|
"@types/ws": "^8.18.1",
|
|
403
401
|
"@types/xast": "^2.0.4",
|
|
404
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
402
|
+
"@typescript/native-preview": "7.0.0-dev.20260122.4",
|
|
405
403
|
"@vitest/coverage-v8": "^3.2.4",
|
|
406
404
|
"ajv-keywords": "^5.1.0",
|
|
407
405
|
"code-inspector-plugin": "1.3.3",
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { boolean, integer, pgTable, primaryKey, text, timestamp } from 'drizzle-orm/pg-core';
|
|
2
|
-
import { AdapterAccount } from 'next-auth/adapters';
|
|
3
2
|
|
|
4
3
|
import { users } from './user';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* NextAuth account type (oauth, email, credentials, etc.)
|
|
7
|
+
* Previously imported from next-auth/adapters, now defined locally to remove dependency
|
|
8
|
+
*/
|
|
9
|
+
type AccountType = 'credentials' | 'email' | 'oauth' | 'oidc' | 'webauthn';
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* This table stores nextauth accounts. This is used to link users to their sso profiles.
|
|
8
13
|
* @see {@link https://authjs.dev/guides/creating-a-database-adapter#database-session-management | NextAuth Doc}
|
|
@@ -19,7 +24,7 @@ export const nextauthAccounts = pgTable(
|
|
|
19
24
|
scope: text('scope'),
|
|
20
25
|
session_state: text('session_state'),
|
|
21
26
|
token_type: text('token_type'),
|
|
22
|
-
type: text('type').$type<
|
|
27
|
+
type: text('type').$type<AccountType>().notNull(),
|
|
23
28
|
userId: text('user_id')
|
|
24
29
|
.notNull()
|
|
25
30
|
.references(() => users.id, { onDelete: 'cascade' }),
|