@lobehub/chat 1.12.20 → 1.13.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.
- package/CHANGELOG.md +25 -0
- package/docs/self-hosting/advanced/auth/next-auth/authelia.mdx +75 -0
- package/docs/self-hosting/advanced/auth/next-auth/authelia.zh-CN.mdx +73 -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 +10 -0
- package/src/libs/next-auth/sso-providers/authelia.ts +40 -0
- package/src/libs/next-auth/sso-providers/index.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## [Version 1.13.0](https://github.com/lobehub/lobe-chat/compare/v1.12.20...v1.13.0)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-08-27**</sup>
|
|
8
|
+
|
|
9
|
+
#### ✨ Features
|
|
10
|
+
|
|
11
|
+
- **misc**: Supports Authelia login.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's improved
|
|
19
|
+
|
|
20
|
+
- **misc**: Supports Authelia login, closes [#3589](https://github.com/lobehub/lobe-chat/issues/3589) ([2141ae7](https://github.com/lobehub/lobe-chat/commit/2141ae7))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
5
30
|
### [Version 1.12.20](https://github.com/lobehub/lobe-chat/compare/v1.12.19...v1.12.20)
|
|
6
31
|
|
|
7
32
|
<sup>Released on **2024-08-26**</sup>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Configuring Authelia Authentication Service for LobeChat
|
|
3
|
+
description: >-
|
|
4
|
+
Learn how to configure Authelia authentication service in LobeChat, including
|
|
5
|
+
creating a provider, configuring environment variables, and deploying
|
|
6
|
+
LobeChat. Detailed steps and necessary environment variable settings.
|
|
7
|
+
tags:
|
|
8
|
+
- Authelia Configuration
|
|
9
|
+
- Single Sign-On (SSO)
|
|
10
|
+
- LobeChat Authentication
|
|
11
|
+
- Environment Variables
|
|
12
|
+
- Deployment Instructions
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Configuring Authelia Authentication Service
|
|
16
|
+
|
|
17
|
+
## Authelia Configuration Flow
|
|
18
|
+
|
|
19
|
+
<Steps>
|
|
20
|
+
### Create an Authelia Identity Provider
|
|
21
|
+
|
|
22
|
+
We assume you are already familiar with using Authelia. Let's say your LobeChat instance is deployed at https://lobe.example.com/.
|
|
23
|
+
Note that currently only localhost supports HTTP access; other domains need to enable TLS, otherwise Authelia will actively interrupt authentication by default.
|
|
24
|
+
|
|
25
|
+
Now, let's open and edit the configuration file of your Authelia instance:
|
|
26
|
+
|
|
27
|
+
Add a new lobe-chat item under identity_providers -> oidc:
|
|
28
|
+
|
|
29
|
+
```yaml
|
|
30
|
+
identity_providers:
|
|
31
|
+
oidc:
|
|
32
|
+
...
|
|
33
|
+
## The other portions of the mandatory OpenID Connect 1.0 configuration go here.
|
|
34
|
+
## See: https://www.authelia.com/c/oidc
|
|
35
|
+
- id: lobe-chat
|
|
36
|
+
description: LobeChat
|
|
37
|
+
secret: '$pbkdf2-sha512$310000$c8p78n7pUMln0jzvd4aK4Q$JNRBzwAo0ek5qKn50cFzzvE9RXV88h1wJn5KGiHrD0YKtZaR/nCb2CJPOsKaPK0hjf.9yHxzQGZziziccp6Yng' # The digest of 'insecure_secret'.
|
|
38
|
+
public: false
|
|
39
|
+
authorization_policy: two_factor
|
|
40
|
+
redirect_uris:
|
|
41
|
+
- https://chat.example.com/api/auth/callback/authelia
|
|
42
|
+
scopes:
|
|
43
|
+
- openid
|
|
44
|
+
- profile
|
|
45
|
+
- email
|
|
46
|
+
userinfo_signing_algorithm: none
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Make sure to replace secret and redirect_urls with your own values.
|
|
50
|
+
Note! The secret configured in Authelia is ciphertext, i.e., a salted hash value. Its corresponding plaintext needs to be filled in LobeChat later.
|
|
51
|
+
|
|
52
|
+
Save the configuration file and restart the Authelia service. Now we have completed the Authelia configuration.
|
|
53
|
+
|
|
54
|
+
### Configure Environment Variables
|
|
55
|
+
|
|
56
|
+
When deploying LobeChat, you need to configure the following environment variables:
|
|
57
|
+
|
|
58
|
+
| Environment Variable | Type | Description |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `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` |
|
|
61
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | Required | Select the SSO provider for LoboChat. Use `authentik` for Authentik. |
|
|
62
|
+
| `AUTHELIA_CLIENT_ID` | Required | The id just configured in Authelia, example value is lobe-chat |
|
|
63
|
+
| `AUTHELIA_CLIENT_SECRET` | The plaintext corresponding to the secret just configured in Authelia, example value is insecure_secret |
|
|
64
|
+
| `AUTHELIA_ISSUER` | Required | Your Authelia URL, for example https://sso.example.com |
|
|
65
|
+
| `NEXTAUTH_URL` | Optional | This URL is used to specify the callback address for Auth.js when performing OAuth verification. It only needs to be set when the default generated redirect address is incorrect. https://chat.example.com/api/auth |
|
|
66
|
+
|
|
67
|
+
<Callout type={'tip'}>
|
|
68
|
+
Go to [📘 Environment Variables](/docs/self-hosting/environment-variable#Authelia) for details about the variables.
|
|
69
|
+
</Callout>
|
|
70
|
+
</Steps>
|
|
71
|
+
|
|
72
|
+
<Callout type={'info'}>
|
|
73
|
+
After a successful deployment, users will be able to use LobeChat by authenticating with the users
|
|
74
|
+
configured in Authelia.
|
|
75
|
+
</Callout>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 在 LobeChat 中配置 Authelia 身份验证服务
|
|
3
|
+
description: 学习如何在 LobeChat 中配置 Authelia 身份验证服务,包括创建提供程序、配置环境变量和部署 LobeChat。详细步骤和必要环境变量设置。
|
|
4
|
+
tags:
|
|
5
|
+
- Authelia
|
|
6
|
+
- 身份验证
|
|
7
|
+
- 单点登录
|
|
8
|
+
- 环境变量
|
|
9
|
+
- LobeChat
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# 配置 Authelia 身份验证服务
|
|
13
|
+
|
|
14
|
+
## Authelia 配置流程
|
|
15
|
+
|
|
16
|
+
<Steps>
|
|
17
|
+
### 创建 Authelia 提供应用
|
|
18
|
+
|
|
19
|
+
我们现在默认您已经了解了如何使用 Authelia。假设您的 LobeChat 实例部署在 `https://lobe.example.com/` 中。
|
|
20
|
+
注意,目前只有 `localhost` 支持 HTTP 访问,其他域名需要启用 TLS,否则 Authelia 默认将主动中断身份认证。
|
|
21
|
+
|
|
22
|
+
现在,我们打开 Authelia 实例的配置文件进行编辑:
|
|
23
|
+
|
|
24
|
+
在 `identity_providers`-> `oidc` 下新增一个 `lobe-chat` 的项目:
|
|
25
|
+
|
|
26
|
+
```yaml
|
|
27
|
+
...
|
|
28
|
+
identity_providers:
|
|
29
|
+
oidc:
|
|
30
|
+
...
|
|
31
|
+
## The other portions of the mandatory OpenID Connect 1.0 configuration go here.
|
|
32
|
+
## See: https://www.authelia.com/c/oidc
|
|
33
|
+
- id: lobe-chat
|
|
34
|
+
description: LobeChat
|
|
35
|
+
secret: '$pbkdf2-sha512$310000$c8p78n7pUMln0jzvd4aK4Q$JNRBzwAo0ek5qKn50cFzzvE9RXV88h1wJn5KGiHrD0YKtZaR/nCb2CJPOsKaPK0hjf.9yHxzQGZziziccp6Yng' # The digest of 'insecure_secret'.
|
|
36
|
+
public: false
|
|
37
|
+
authorization_policy: two_factor
|
|
38
|
+
redirect_uris:
|
|
39
|
+
- https://chat.example.com/api/auth/callback/authelia
|
|
40
|
+
scopes:
|
|
41
|
+
- openid
|
|
42
|
+
- profile
|
|
43
|
+
- email
|
|
44
|
+
userinfo_signing_algorithm: none
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
请您确保 `secret` 和 `redirect_urls` 替换成您自己的值。
|
|
48
|
+
注意!Authelia 中配置 `secret` 是密文,即加盐哈希值。其对应的明文稍后需要填写在 lobeChat 中。
|
|
49
|
+
|
|
50
|
+
保存配置文件,然后重启 Authelia 服务。现在我们完成了 Authelia 的配置工作。
|
|
51
|
+
|
|
52
|
+
### 配置环境变量
|
|
53
|
+
|
|
54
|
+
在部署 LobeChat 时,你需要配置以下环境变量:
|
|
55
|
+
|
|
56
|
+
| 环境变量 | 类型 | 描述 |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
|
|
59
|
+
| `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Authelia 请填写 `authelia`。 |
|
|
60
|
+
| `AUTHELIA_CLIENT_ID` | 必选 | 刚刚在 Authelia 配置的 `id`,示例值是 `lobe-chat` |
|
|
61
|
+
| `AUTHELIA_CLIENT_SECRET` | 必选 | 刚刚在 Authelia 配置的 `secret` 对应的明文,示例值是 `insecure_secret` |
|
|
62
|
+
| `AUTHELIA_ISSUER` | 必选 |您的 Authelia 的网址,例如 `https://sso.example.com` |
|
|
63
|
+
| `NEXTAUTH_URL` | 可选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://chat.example.com/api/auth` |
|
|
64
|
+
|
|
65
|
+
<Callout type={'tip'}>
|
|
66
|
+
前往 [📘 环境变量](/docs/self-hosting/environment-variable#Authelia) 可查阅相关变量详情。
|
|
67
|
+
|
|
68
|
+
</Callout>
|
|
69
|
+
</Steps>
|
|
70
|
+
|
|
71
|
+
<Callout type={'info'}>
|
|
72
|
+
部署成功后,用户将可以使用 Authelia 中配置的用户通过身份认证并使用 LobeChat。
|
|
73
|
+
</Callout>
|
|
@@ -109,6 +109,29 @@ LobeChat provides a complete authentication service capability when deployed. Th
|
|
|
109
109
|
- Default: `-`
|
|
110
110
|
- Example: `https://your-authentik-domain.com/application/o/slug/`
|
|
111
111
|
|
|
112
|
+
### Authelia
|
|
113
|
+
|
|
114
|
+
#### `AUTHELIA_CLIENT_ID`
|
|
115
|
+
|
|
116
|
+
- Type: Required
|
|
117
|
+
- Description: Client ID of the Authelia provider application. You can access it [here][auth0-client-page] and navigate to the application settings to view.
|
|
118
|
+
- Default: `-`
|
|
119
|
+
- Example: `lobe-chat`
|
|
120
|
+
|
|
121
|
+
#### `AUTHELIA_CLIENT_SECRET`
|
|
122
|
+
|
|
123
|
+
- Type: Required
|
|
124
|
+
- Description: The plaintext of the Client Secret for the Authelia provider
|
|
125
|
+
- Default: `-`
|
|
126
|
+
- Example: `insecure_secret`
|
|
127
|
+
|
|
128
|
+
#### `AUTHELIA_ISSUER`
|
|
129
|
+
|
|
130
|
+
- Type: Required
|
|
131
|
+
- Description: Issuer of the Authelia provider application.
|
|
132
|
+
- Default: `-`
|
|
133
|
+
- Example: `https://sso.example.com`
|
|
134
|
+
|
|
112
135
|
### Github
|
|
113
136
|
|
|
114
137
|
#### `GITHUB_CLIENT_ID`
|
|
@@ -107,6 +107,29 @@ LobeChat 在部署时提供了完善的身份验证服务能力,以下是相
|
|
|
107
107
|
- 默认值: `-`
|
|
108
108
|
- 示例: `https://your-authentik-domain.com/application/o/slug/`
|
|
109
109
|
|
|
110
|
+
### Authelia
|
|
111
|
+
|
|
112
|
+
#### `AUTHELIA_CLIENT_ID`
|
|
113
|
+
|
|
114
|
+
- 类型:必选
|
|
115
|
+
- 描述: Authelia 提供程序的 Client ID
|
|
116
|
+
- 默认值: `-`
|
|
117
|
+
- 示例: `lobe-chat`
|
|
118
|
+
|
|
119
|
+
#### `AUTHELIA_CLIENT_SECRET`
|
|
120
|
+
|
|
121
|
+
- 类型:必选
|
|
122
|
+
- 描述: Authelia 提供程序的 Client Secret 的明文
|
|
123
|
+
- 默认值: `-`
|
|
124
|
+
- 示例: `insecure_secret`
|
|
125
|
+
|
|
126
|
+
#### `AUTHELIA_ISSUER`
|
|
127
|
+
|
|
128
|
+
- 类型:必选
|
|
129
|
+
- 描述: Authentik 提供程序的 OpenID Connect 颁发者
|
|
130
|
+
- 默认值: `-`
|
|
131
|
+
- 示例: `https://sso.example.com`
|
|
132
|
+
|
|
110
133
|
### Github
|
|
111
134
|
|
|
112
135
|
#### `GITHUB_CLIENT_ID`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
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
|
@@ -81,6 +81,11 @@ export const getAuthConfig = () => {
|
|
|
81
81
|
AUTHENTIK_CLIENT_SECRET: z.string().optional(),
|
|
82
82
|
AUTHENTIK_ISSUER: z.string().optional(),
|
|
83
83
|
|
|
84
|
+
// AUTHELIA
|
|
85
|
+
AUTHELIA_CLIENT_ID: z.string().optional(),
|
|
86
|
+
AUTHELIA_CLIENT_SECRET: z.string().optional(),
|
|
87
|
+
AUTHELIA_ISSUER: z.string().optional(),
|
|
88
|
+
|
|
84
89
|
// ZITADEL
|
|
85
90
|
ZITADEL_CLIENT_ID: z.string().optional(),
|
|
86
91
|
ZITADEL_CLIENT_SECRET: z.string().optional(),
|
|
@@ -118,6 +123,11 @@ export const getAuthConfig = () => {
|
|
|
118
123
|
AUTHENTIK_CLIENT_SECRET: process.env.AUTHENTIK_CLIENT_SECRET,
|
|
119
124
|
AUTHENTIK_ISSUER: process.env.AUTHENTIK_ISSUER,
|
|
120
125
|
|
|
126
|
+
// AUTHELIA
|
|
127
|
+
AUTHELIA_CLIENT_ID: process.env.AUTHELIA_CLIENT_ID,
|
|
128
|
+
AUTHELIA_CLIENT_SECRET: process.env.AUTHELIA_CLIENT_SECRET,
|
|
129
|
+
AUTHELIA_ISSUER: process.env.AUTHELIA_ISSUER,
|
|
130
|
+
|
|
121
131
|
// ZITADEL
|
|
122
132
|
ZITADEL_CLIENT_ID: process.env.ZITADEL_CLIENT_ID,
|
|
123
133
|
ZITADEL_CLIENT_SECRET: process.env.ZITADEL_CLIENT_SECRET,
|
|
@@ -0,0 +1,40 @@
|
|
|
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 AutheliaProfile = {
|
|
8
|
+
// The users display name
|
|
9
|
+
email: string;
|
|
10
|
+
// The users email
|
|
11
|
+
groups: string[];
|
|
12
|
+
// The username the user used to login with
|
|
13
|
+
name: string;
|
|
14
|
+
preferred_username: string; // The users groups
|
|
15
|
+
sub: string; // The users id
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const provider = {
|
|
19
|
+
id: 'authelia',
|
|
20
|
+
provider: {
|
|
21
|
+
...CommonProviderConfig,
|
|
22
|
+
authorization: { params: { scope: 'openid email profile' } },
|
|
23
|
+
checks: ['state', 'pkce'],
|
|
24
|
+
clientId: authEnv.AUTHELIA_CLIENT_ID,
|
|
25
|
+
clientSecret: authEnv.AUTHELIA_CLIENT_SECRET,
|
|
26
|
+
id: 'authelia',
|
|
27
|
+
issuer: authEnv.AUTHELIA_ISSUER,
|
|
28
|
+
name: 'Authelia',
|
|
29
|
+
profile(profile) {
|
|
30
|
+
return {
|
|
31
|
+
email: profile.email,
|
|
32
|
+
name: profile.name,
|
|
33
|
+
providerAccountId: profile.sub,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
type: 'oidc',
|
|
37
|
+
} satisfies OIDCConfig<AutheliaProfile>,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default provider;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import Auth0 from './auth0';
|
|
2
|
+
import Authelia from './authelia';
|
|
2
3
|
import Authentik from './authentik';
|
|
3
4
|
import AzureAD from './azure-ad';
|
|
4
5
|
import Github from './github';
|
|
5
6
|
import Zitadel from './zitadel';
|
|
6
7
|
|
|
7
|
-
export const ssoProviders = [Auth0, Authentik, AzureAD, Github, Zitadel];
|
|
8
|
+
export const ssoProviders = [Auth0, Authentik, AzureAD, Github, Zitadel, Authelia];
|