@lobehub/lobehub 2.0.0-next.125 → 2.0.0-next.127
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 +3 -1
- package/changelog/v1.json +18 -0
- package/docs/self-hosting/advanced/auth.mdx +7 -0
- package/docs/self-hosting/advanced/auth.zh-CN.mdx +7 -0
- package/package.json +1 -1
- package/src/envs/auth.test.ts +60 -0
- package/src/envs/auth.ts +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 2.0.0-next.127](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.126...v2.0.0-next.127)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2025-11-27**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Better-auth fallback next-auth providers env.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Better-auth fallback next-auth providers env, closes [#10459](https://github.com/lobehub/lobe-chat/issues/10459) ([e167075](https://github.com/lobehub/lobe-chat/commit/e167075))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
## [Version 2.0.0-next.126](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.125...v2.0.0-next.126)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2025-11-27**</sup>
|
|
33
|
+
|
|
34
|
+
#### 🐛 Bug Fixes
|
|
35
|
+
|
|
36
|
+
- **misc**: Align docker auth defaults and better-auth docs.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### What's fixed
|
|
44
|
+
|
|
45
|
+
- **misc**: Align docker auth defaults and better-auth docs, closes [#10457](https://github.com/lobehub/lobe-chat/issues/10457) ([1375314](https://github.com/lobehub/lobe-chat/commit/1375314))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
## [Version 2.0.0-next.125](https://github.com/lobehub/lobe-chat/compare/v2.0.0-next.124...v2.0.0-next.125)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2025-11-27**</sup>
|
package/Dockerfile
CHANGED
|
@@ -38,6 +38,7 @@ FROM base AS builder
|
|
|
38
38
|
ARG USE_CN_MIRROR
|
|
39
39
|
ARG NEXT_PUBLIC_BASE_PATH
|
|
40
40
|
ARG NEXT_PUBLIC_ENABLE_BETTER_AUTH
|
|
41
|
+
ARG NEXT_PUBLIC_ENABLE_NEXT_AUTH
|
|
41
42
|
ARG NEXT_PUBLIC_ENABLE_CLERK_AUTH
|
|
42
43
|
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
|
|
43
44
|
ARG NEXT_PUBLIC_SENTRY_DSN
|
|
@@ -52,7 +53,8 @@ ARG FEATURE_FLAGS
|
|
|
52
53
|
ENV NEXT_PUBLIC_BASE_PATH="${NEXT_PUBLIC_BASE_PATH}" \
|
|
53
54
|
FEATURE_FLAGS="${FEATURE_FLAGS}"
|
|
54
55
|
|
|
55
|
-
ENV NEXT_PUBLIC_ENABLE_BETTER_AUTH="${NEXT_PUBLIC_ENABLE_BETTER_AUTH:-
|
|
56
|
+
ENV NEXT_PUBLIC_ENABLE_BETTER_AUTH="${NEXT_PUBLIC_ENABLE_BETTER_AUTH:-0}" \
|
|
57
|
+
NEXT_PUBLIC_ENABLE_NEXT_AUTH="${NEXT_PUBLIC_ENABLE_NEXT_AUTH:-1}" \
|
|
56
58
|
NEXT_PUBLIC_ENABLE_CLERK_AUTH="${NEXT_PUBLIC_ENABLE_CLERK_AUTH:-0}" \
|
|
57
59
|
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY="${NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY}" \
|
|
58
60
|
CLERK_WEBHOOK_SECRET="whsec_xxx" \
|
package/changelog/v1.json
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"children": {
|
|
4
|
+
"fixes": [
|
|
5
|
+
"Better-auth fallback next-auth providers env."
|
|
6
|
+
]
|
|
7
|
+
},
|
|
8
|
+
"date": "2025-11-27",
|
|
9
|
+
"version": "2.0.0-next.127"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"children": {
|
|
13
|
+
"fixes": [
|
|
14
|
+
"Align docker auth defaults and better-auth docs."
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
"date": "2025-11-27",
|
|
18
|
+
"version": "2.0.0-next.126"
|
|
19
|
+
},
|
|
2
20
|
{
|
|
3
21
|
"children": {
|
|
4
22
|
"features": [
|
|
@@ -46,6 +46,13 @@ To enable Better Auth in LobeChat, set the following environment variables:
|
|
|
46
46
|
| `NEXT_PUBLIC_AUTH_URL` | Optional | The URL accessible from the browser for Better Auth callbacks. Only set this if the default generated URL is incorrect |
|
|
47
47
|
| `AUTH_SSO_PROVIDERS` | Optional | Comma-separated list of enabled SSO providers, e.g., `google,github,microsoft` |
|
|
48
48
|
|
|
49
|
+
<Callout type={'warning'}>
|
|
50
|
+
If you build/deploy with the official Docker image, the defaults keep **NextAuth enabled** and **Better
|
|
51
|
+
Auth disabled** (`NEXT_PUBLIC_ENABLE_NEXT_AUTH=1`, `NEXT_PUBLIC_ENABLE_BETTER_AUTH=0`) to avoid unexpected
|
|
52
|
+
login redirects. To switch to Better Auth, set both build args and runtime envs explicitly:
|
|
53
|
+
`NEXT_PUBLIC_ENABLE_BETTER_AUTH=1` and `NEXT_PUBLIC_ENABLE_NEXT_AUTH=0`, then rebuild the image.
|
|
54
|
+
</Callout>
|
|
55
|
+
|
|
49
56
|
### Supported SSO Providers
|
|
50
57
|
|
|
51
58
|
| Provider | Value | Environment Variables |
|
|
@@ -44,6 +44,13 @@ LobeChat 与 Clerk 做了深度集成,能够为用户提供一个更加安全
|
|
|
44
44
|
| `NEXT_PUBLIC_AUTH_URL` | 可选 | 浏览器可访问的 Better Auth 回调 URL。仅在默认生成的 URL 不正确时设置 |
|
|
45
45
|
| `AUTH_SSO_PROVIDERS` | 可选 | 启用的 SSO 提供商列表,以逗号分隔,例如 `google,github,microsoft` |
|
|
46
46
|
|
|
47
|
+
<Callout type={'warning'}>
|
|
48
|
+
若使用官方 Docker 镜像构建 / 部署,默认是 **开启 NextAuth、关闭 Better Auth**
|
|
49
|
+
(`NEXT_PUBLIC_ENABLE_NEXT_AUTH=1`、`NEXT_PUBLIC_ENABLE_BETTER_AUTH=0`),以避免意外跳转到新版登录页。
|
|
50
|
+
如果要切换到 Better Auth,请同时显式设置构建参数和运行时环境变量:
|
|
51
|
+
`NEXT_PUBLIC_ENABLE_BETTER_AUTH=1`、`NEXT_PUBLIC_ENABLE_NEXT_AUTH=0`,并重新构建镜像。
|
|
52
|
+
</Callout>
|
|
53
|
+
|
|
47
54
|
### 支持的 SSO 提供商
|
|
48
55
|
|
|
49
56
|
| 提供商 | 值 | 环境变量 |
|
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.127",
|
|
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",
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { getAuthConfig } from './auth';
|
|
4
|
+
|
|
5
|
+
const ORIGINAL_ENV = { ...process.env };
|
|
6
|
+
const ORIGINAL_WINDOW = globalThis.window;
|
|
7
|
+
|
|
8
|
+
describe('getAuthConfig fallbacks', () => {
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
// reset env to a clean clone before each test
|
|
11
|
+
process.env = { ...ORIGINAL_ENV };
|
|
12
|
+
globalThis.window = ORIGINAL_WINDOW;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
process.env = { ...ORIGINAL_ENV };
|
|
17
|
+
globalThis.window = ORIGINAL_WINDOW;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should fall back to NEXT_AUTH_SSO_PROVIDERS when AUTH_SSO_PROVIDERS is empty string', () => {
|
|
21
|
+
process.env.AUTH_SSO_PROVIDERS = '';
|
|
22
|
+
process.env.NEXT_AUTH_SSO_PROVIDERS = 'logto,github';
|
|
23
|
+
|
|
24
|
+
// Simulate server runtime so @t3-oss/env treats this as server-side access
|
|
25
|
+
// (happy-dom sets window by default in Vitest)
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
27
|
+
// @ts-expect-error - allow overriding for test
|
|
28
|
+
globalThis.window = undefined;
|
|
29
|
+
|
|
30
|
+
const config = getAuthConfig();
|
|
31
|
+
|
|
32
|
+
expect(config.AUTH_SSO_PROVIDERS).toBe('logto,github');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should fall back to NEXT_AUTH_SECRET when AUTH_SECRET is empty string', () => {
|
|
36
|
+
process.env.AUTH_SECRET = '';
|
|
37
|
+
process.env.NEXT_AUTH_SECRET = 'nextauth-secret';
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
40
|
+
// @ts-expect-error - allow overriding for test
|
|
41
|
+
globalThis.window = undefined;
|
|
42
|
+
|
|
43
|
+
const config = getAuthConfig();
|
|
44
|
+
|
|
45
|
+
expect(config.AUTH_SECRET).toBe('nextauth-secret');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should fall back to NEXTAUTH_URL origin when NEXT_PUBLIC_AUTH_URL is empty string', () => {
|
|
49
|
+
process.env.NEXT_PUBLIC_AUTH_URL = '';
|
|
50
|
+
process.env.NEXTAUTH_URL = 'https://example.com/api/auth';
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
53
|
+
// @ts-expect-error - allow overriding for test
|
|
54
|
+
globalThis.window = undefined;
|
|
55
|
+
|
|
56
|
+
const config = getAuthConfig();
|
|
57
|
+
|
|
58
|
+
expect(config.NEXT_PUBLIC_AUTH_URL).toBe('https://example.com');
|
|
59
|
+
});
|
|
60
|
+
});
|
package/src/envs/auth.ts
CHANGED
|
@@ -237,14 +237,14 @@ export const getAuthConfig = () => {
|
|
|
237
237
|
NEXT_PUBLIC_ENABLE_BETTER_AUTH: process.env.NEXT_PUBLIC_ENABLE_BETTER_AUTH === '1',
|
|
238
238
|
// Fallback to NEXTAUTH_URL origin for seamless migration from next-auth
|
|
239
239
|
NEXT_PUBLIC_AUTH_URL:
|
|
240
|
-
process.env.NEXT_PUBLIC_AUTH_URL
|
|
240
|
+
process.env.NEXT_PUBLIC_AUTH_URL ||
|
|
241
241
|
(process.env.NEXTAUTH_URL ? new URL(process.env.NEXTAUTH_URL).origin : undefined),
|
|
242
242
|
NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION: process.env.NEXT_PUBLIC_AUTH_EMAIL_VERIFICATION === '1',
|
|
243
243
|
NEXT_PUBLIC_ENABLE_MAGIC_LINK: process.env.NEXT_PUBLIC_ENABLE_MAGIC_LINK === '1',
|
|
244
244
|
// Fallback to NEXT_AUTH_SECRET for seamless migration from next-auth
|
|
245
|
-
AUTH_SECRET: process.env.AUTH_SECRET
|
|
245
|
+
AUTH_SECRET: process.env.AUTH_SECRET || process.env.NEXT_AUTH_SECRET,
|
|
246
246
|
// Fallback to NEXT_AUTH_SSO_PROVIDERS for seamless migration from next-auth
|
|
247
|
-
AUTH_SSO_PROVIDERS: process.env.AUTH_SSO_PROVIDERS
|
|
247
|
+
AUTH_SSO_PROVIDERS: process.env.AUTH_SSO_PROVIDERS || process.env.NEXT_AUTH_SSO_PROVIDERS,
|
|
248
248
|
|
|
249
249
|
// better-auth env for Cognito provider is different from next-auth's one
|
|
250
250
|
AUTH_COGNITO_DOMAIN: process.env.AUTH_COGNITO_DOMAIN,
|