@lobehub/chat 1.22.1 → 1.22.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/docker-compose/local/docker-compose.yml +11 -9
  3. package/docker-compose/{local-logto → local/logto}/.env.example +2 -2
  4. package/docker-compose/{local-logto → local/logto}/.env.zh-CN.example +3 -3
  5. package/docker-compose/{local-logto → local/logto}/docker-compose.yml +8 -7
  6. package/docker-compose/local/setup.sh +31 -29
  7. package/docker-compose/local/zitadel/docker-compose.yml +8 -8
  8. package/docker-compose/production/{.env.example → logto/.env.example} +3 -3
  9. package/docker-compose/production/{.env.zh-CN.example → logto/.env.zh-CN.example} +3 -3
  10. package/docker-compose/production/{docker-compose.yml → logto/docker-compose.yml} +2 -1
  11. package/docker-compose/production/zitadel/docker-compose.yml +5 -5
  12. package/docs/self-hosting/advanced/auth/next-auth/authentik.zh-CN.mdx +2 -2
  13. package/docs/self-hosting/advanced/auth/next-auth/casdoor.mdx +120 -0
  14. package/docs/self-hosting/advanced/auth/next-auth/casdoor.zh-CN.mdx +121 -0
  15. package/docs/self-hosting/advanced/auth/next-auth/cloudflare-zero-trust.zh-CN.mdx +3 -3
  16. package/docs/self-hosting/advanced/auth/next-auth/logto.mdx +10 -8
  17. package/docs/self-hosting/advanced/auth/next-auth/logto.zh-CN.mdx +1 -1
  18. package/docs/self-hosting/advanced/auth.mdx +5 -1
  19. package/docs/self-hosting/advanced/auth.zh-CN.mdx +5 -1
  20. package/docs/self-hosting/environment-variables/auth.mdx +88 -63
  21. package/docs/self-hosting/environment-variables/auth.zh-CN.mdx +91 -68
  22. package/docs/self-hosting/server-database/docker-compose.mdx +163 -280
  23. package/docs/self-hosting/server-database/docker-compose.zh-CN.mdx +92 -210
  24. package/docs/usage/providers/ai21.mdx +3 -1
  25. package/docs/usage/providers/ai360.mdx +1 -1
  26. package/docs/usage/providers/fireworksai.mdx +3 -1
  27. package/docs/usage/providers/github.mdx +1 -1
  28. package/docs/usage/providers/hunyuan.mdx +3 -1
  29. package/docs/usage/providers/siliconcloud.mdx +3 -1
  30. package/docs/usage/providers/spark.mdx +1 -1
  31. package/docs/usage/providers/upstage.mdx +1 -1
  32. package/docs/usage/providers/wenxin.mdx +3 -1
  33. package/docs/usage/providers/zeroone.mdx +2 -2
  34. package/package.json +5 -5
  35. package/src/libs/next-auth/sso-providers/logto.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,31 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ### [Version 1.22.2](https://github.com/lobehub/lobe-chat/compare/v1.22.1...v1.22.2)
6
+
7
+ <sup>Released on **2024-10-13**</sup>
8
+
9
+ #### 🐛 Bug Fixes
10
+
11
+ - **misc**: Allow use email as name in logto.
12
+
13
+ <br/>
14
+
15
+ <details>
16
+ <summary><kbd>Improvements and Fixes</kbd></summary>
17
+
18
+ #### What's fixed
19
+
20
+ - **misc**: Allow use email as name in logto, closes [#4350](https://github.com/lobehub/lobe-chat/issues/4350) ([d5a046a](https://github.com/lobehub/lobe-chat/commit/d5a046a))
21
+
22
+ </details>
23
+
24
+ <div align="right">
25
+
26
+ [![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)
27
+
28
+ </div>
29
+
5
30
  ### [Version 1.22.1](https://github.com/lobehub/lobe-chat/compare/v1.22.0...v1.22.1)
6
31
 
7
32
  <sup>Released on **2024-10-12**</sup>
@@ -1,10 +1,11 @@
1
+ name: lobe-chat-database
1
2
  services:
2
3
  network-service:
3
4
  image: alpine
4
5
  container_name: lobe-network
5
6
  ports:
6
- - '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
7
- - '9001:9001' # MinIO Console
7
+ - '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
8
+ - '9001:9001' # MinIO Console
8
9
  - '${CASDOOR_PORT}:${CASDOOR_PORT}' # Casdoor
9
10
  - '${LOBE_PORT}:3210' # LobeChat
10
11
  command: tail -f /dev/null
@@ -15,7 +16,7 @@ services:
15
16
  image: pgvector/pgvector:pg16
16
17
  container_name: lobe-postgres
17
18
  ports:
18
- - "5432:5432"
19
+ - '5432:5432'
19
20
  volumes:
20
21
  - './data:/var/lib/postgresql/data'
21
22
  environment:
@@ -44,6 +45,7 @@ services:
44
45
  command: >
45
46
  server /etc/minio/data --address ":${MINIO_PORT}" --console-address ":9001"
46
47
 
48
+
47
49
  casdoor:
48
50
  image: casbin/casdoor
49
51
  container_name: lobe-casdoor
@@ -53,17 +55,17 @@ services:
53
55
  postgresql:
54
56
  condition: service_healthy
55
57
  environment:
56
- RUNNING_IN_DOCKER: "true"
57
- driverName: "postgres"
58
- dataSourceName: "user=postgres password=${POSTGRES_PASSWORD} host=postgresql port=5432 sslmode=disable dbname=casdoor"
59
- origin: "http://localhost:${CASDOOR_PORT}"
60
- runmode: "dev"
58
+ RUNNING_IN_DOCKER: 'true'
59
+ driverName: 'postgres'
60
+ dataSourceName: 'user=postgres password=${POSTGRES_PASSWORD} host=postgresql port=5432 sslmode=disable dbname=casdoor'
61
+ origin: 'http://localhost:${CASDOOR_PORT}'
62
+ runmode: 'dev'
61
63
  volumes:
62
64
  - ./init_data.json:/init_data.json
63
65
 
64
66
  lobe:
65
67
  image: lobehub/lobe-chat-database
66
- container_name: lobe-database
68
+ container_name: lobe-chat
67
69
  network_mode: 'service:network-service'
68
70
  depends_on:
69
71
  postgresql:
@@ -1,6 +1,6 @@
1
1
  # Logto secret
2
- LOGTO_CLIENT_ID=
3
- LOGTO_CLIENT_SECRET=
2
+ AUTH_LOGTO_CLIENT_ID=
3
+ AUTH_LOGTO_CLIENT_SECRET=
4
4
 
5
5
  # MinIO S3 configuration
6
6
  MINIO_ROOT_USER=YOUR_MINIO_USER
@@ -1,6 +1,6 @@
1
- # Logto secret
2
- LOGTO_CLIENT_ID=
3
- LOGTO_CLIENT_SECRET=
1
+ # Logto 鉴权相关
2
+ AUTH_LOGTO_CLIENT_ID=
3
+ AUTH_LOGTO_CLIENT_SECRET=
4
4
 
5
5
  # MinIO S3 配置
6
6
  MINIO_ROOT_USER=YOUR_MINIO_USER
@@ -1,12 +1,13 @@
1
+ name: lobe-chat-database
1
2
  services:
2
3
  network-service:
3
4
  image: alpine
4
5
  container_name: lobe-network
5
6
  ports:
6
- - '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
7
- - '9001:9001' # MinIO Console
7
+ - '${MINIO_PORT}:${MINIO_PORT}' # MinIO API
8
+ - '9001:9001' # MinIO Console
8
9
  - '${LOGTO_PORT}:${LOGTO_PORT}' # Logto
9
- - '3002:3002' # Logto Admin
10
+ - '3002:3002' # Logto Admin
10
11
  - '${LOBE_PORT}:3210' # LobeChat
11
12
  command: tail -f /dev/null
12
13
  networks:
@@ -16,7 +17,7 @@ services:
16
17
  image: pgvector/pgvector:pg16
17
18
  container_name: lobe-postgres
18
19
  ports:
19
- - "5432:5432"
20
+ - '5432:5432'
20
21
  volumes:
21
22
  - './data:/var/lib/postgresql/data'
22
23
  environment:
@@ -45,6 +46,7 @@ services:
45
46
  command: >
46
47
  server /etc/minio/data --address ":${MINIO_PORT}" --console-address ":9001"
47
48
 
49
+
48
50
  logto:
49
51
  image: svhd/logto
50
52
  container_name: lobe-logto
@@ -60,10 +62,9 @@ services:
60
62
  - 'ADMIN_ENDPOINT=http://localhost:3002'
61
63
  entrypoint: ['sh', '-c', 'npm run cli db seed -- --swe && npm start']
62
64
 
63
-
64
65
  lobe:
65
66
  image: lobehub/lobe-chat-database
66
- container_name: lobe-database
67
+ container_name: lobe-chat
67
68
  network_mode: 'service:network-service'
68
69
  depends_on:
69
70
  postgresql:
@@ -81,7 +82,7 @@ services:
81
82
  - 'KEY_VAULTS_SECRET=Kix2wcUONd4CX51E/ZPAd36BqM4wzJgKjPtz2sGztqQ='
82
83
  - 'NEXT_AUTH_SECRET=NX2kaPE923dt6BL2U8e9oSre5RfoT7hg'
83
84
  - 'NEXTAUTH_URL=http://localhost:${LOBE_PORT}/api/auth'
84
- - 'LOGTO_ISSUER=http://localhost:${LOGTO_PORT}/oidc'
85
+ - 'AUTH_LOGTO_ISSUER=http://localhost:${LOGTO_PORT}/oidc'
85
86
  - 'DATABASE_URL=postgresql://postgres:${POSTGRES_PASSWORD}@postgresql:5432/${LOBE_DB_NAME}'
86
87
  - 'S3_ENDPOINT=http://localhost:${MINIO_PORT}'
87
88
  - 'S3_BUCKET=${MINIO_LOBE_BUCKET}'
@@ -9,7 +9,7 @@
9
9
  # ======================
10
10
 
11
11
  # 1. Default values of arguments
12
- # Arg: -f
12
+ # Arg: -f
13
13
  # Determine force download asserts, default is not
14
14
  FORCE_DOWNLOAD=false
15
15
 
@@ -33,10 +33,12 @@ while getopts "fl:-:" opt; do
33
33
  -)
34
34
  case "${OPTARG}" in
35
35
  lang)
36
- LANGUAGE="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
36
+ LANGUAGE="${!OPTIND}"
37
+ OPTIND=$(($OPTIND + 1))
37
38
  ;;
38
39
  url)
39
- SOURCE_URL="${!OPTIND}"; OPTIND=$(( $OPTIND + 1 ))
40
+ SOURCE_URL="${!OPTIND}"
41
+ OPTIND=$(($OPTIND + 1))
40
42
  ;;
41
43
  *)
42
44
  echo "Usage: $0 [-f] [-l language|--lang language] [--url source]" >&2
@@ -51,7 +53,6 @@ while getopts "fl:-:" opt; do
51
53
  esac
52
54
  done
53
55
 
54
-
55
56
  # ===============
56
57
  # == Variables ==
57
58
  # ===============
@@ -161,7 +162,7 @@ show_message() {
161
162
  ;;
162
163
  esac
163
164
  ;;
164
- esac
165
+ esac
165
166
  }
166
167
 
167
168
  # Function to download files
@@ -186,7 +187,7 @@ extract_file() {
186
187
  if [ $? -eq 0 ]; then
187
188
  echo "$file_name" $(show_message "extracted_success") "$target_dir"
188
189
  else
189
- echo "$file_name" $(show_message "extracted_failed")
190
+ echo "$file_name" $(show_message "extracted_failed")
190
191
  exit 1
191
192
  fi
192
193
  else
@@ -198,30 +199,30 @@ extract_file() {
198
199
  # Define colors
199
200
  declare -A colors
200
201
  colors=(
201
- [black]="\e[30m"
202
- [red]="\e[31m"
203
- [green]="\e[32m"
204
- [yellow]="\e[33m"
205
- [blue]="\e[34m"
206
- [magenta]="\e[35m"
207
- [cyan]="\e[36m"
208
- [white]="\e[37m"
209
- [reset]="\e[0m"
202
+ [black]="\e[30m"
203
+ [red]="\e[31m"
204
+ [green]="\e[32m"
205
+ [yellow]="\e[33m"
206
+ [blue]="\e[34m"
207
+ [magenta]="\e[35m"
208
+ [cyan]="\e[36m"
209
+ [white]="\e[37m"
210
+ [reset]="\e[0m"
210
211
  )
211
212
 
212
213
  print_centered() {
213
- local text="$1" # Get input texts
214
- local color="${2:-reset}" # Get color, default to reset
215
- local term_width=$(tput cols) # Get terminal width
216
- local text_length=${#text} # Get text length
217
- local padding=$(( (term_width - text_length) / 2 )) # Get padding
218
- # Check if the color is valid
219
- if [[ -z "${colors[$color]}" ]]; then
220
- echo "Invalid color specified. Available colors: ${!colors[@]}"
221
- return 1
222
- fi
223
- # Print the text with padding
224
- printf "%*s${colors[$color]}%s${colors[reset]}\n" $padding "" "$text"
214
+ local text="$1" # Get input texts
215
+ local color="${2:-reset}" # Get color, default to reset
216
+ local term_width=$(tput cols) # Get terminal width
217
+ local text_length=${#text} # Get text length
218
+ local padding=$(((term_width - text_length) / 2)) # Get padding
219
+ # Check if the color is valid
220
+ if [[ -z "${colors[$color]}" ]]; then
221
+ echo "Invalid color specified. Available colors: ${!colors[@]}"
222
+ return 1
223
+ fi
224
+ # Print the text with padding
225
+ printf "%*s${colors[$color]}%s${colors[reset]}\n" $padding "" "$text"
225
226
  }
226
227
 
227
228
  # Download files asynchronously
@@ -232,10 +233,11 @@ download_file "$SOURCE_URL/${FILES[3]}" "s3_data.tar.gz"
232
233
 
233
234
  # Extract .tar.gz file without output
234
235
  extract_file "s3_data.tar.gz" "."
236
+ rm s3_data.tar.gz
235
237
 
236
238
  # Display final message
237
239
  printf "\n%s\n\n" "$(show_message "tips_run_command")"
238
- print_centered "docker compose -p lobechat-starter up -d" "green"
240
+ print_centered "docker compose up -d" "green"
239
241
  printf "\n%s" "$(show_message "tips_show_documentation")"
240
242
  printf "%s\n" $(show_message "tips_show_documentation_url")
241
- printf "\n\e[33m%s\e[0m\n" "$(show_message "tips_warning")"
243
+ printf "\n\e[33m%s\e[0m\n" "$(show_message "tips_warning")"
@@ -1,10 +1,11 @@
1
+ name: lobe-chat-database
1
2
  services:
2
3
  network-service:
3
4
  image: alpine
4
5
  container_name: lobe-network
5
6
  ports:
6
- - '9000:9000' # MinIO API
7
- - '9001:9001' # MinIO Console
7
+ - '9000:9000' # MinIO API
8
+ - '9001:9001' # MinIO Console
8
9
  - '8080:8080' # Zitadel Console
9
10
  - '3210:3210' # LobeChat
10
11
  command: tail -f /dev/null
@@ -15,7 +16,7 @@ services:
15
16
  image: pgvector/pgvector:pg16
16
17
  container_name: lobe-postgres
17
18
  ports:
18
- - "5432:5432"
19
+ - '5432:5432'
19
20
  volumes:
20
21
  - './data:/var/lib/postgresql/data'
21
22
  environment:
@@ -44,24 +45,23 @@ services:
44
45
  command: >
45
46
  server /etc/minio/data --address ":9000" --console-address ":9001"
46
47
 
48
+
47
49
  zitadel:
48
50
  restart: 'always'
49
51
  image: 'ghcr.io/zitadel/zitadel:latest'
50
52
  container_name: lobe-zitadel
51
53
  network_mode: 'service:network-service'
52
- command: start-from-init --config /zitadel-config.yaml --steps
53
- /zitadel-init-steps.yaml --masterkey "cft3Tekr/rQBOqwoQSCPoncA9BHbn7QJ"
54
- --tlsMode disabled #MasterkeyNeedsToHave32Characters
54
+ command: start-from-init --config /zitadel-config.yaml --steps /zitadel-init-steps.yaml --masterkey "cft3Tekr/rQBOqwoQSCPoncA9BHbn7QJ" --tlsMode disabled #MasterkeyNeedsToHave32Characters
55
55
  volumes:
56
56
  - ./zitadel-config.yaml:/zitadel-config.yaml:ro
57
- - ./zitadel-init-steps.yaml:/zitadel-init-steps.yaml:ro
57
+ - ./zitadel-init-steps.yaml:/zitadel-init-steps.yaml:ro
58
58
  depends_on:
59
59
  postgresql:
60
60
  condition: service_healthy
61
61
 
62
62
  lobe:
63
63
  image: lobehub/lobe-chat-database
64
- container_name: lobe-database
64
+ container_name: lobe-chat
65
65
  network_mode: 'service:network-service'
66
66
  depends_on:
67
67
  postgresql:
@@ -23,9 +23,9 @@ NEXTAUTH_URL=https://lobe.example.com/api/auth
23
23
 
24
24
  # NextAuth providers configuration (example using Logto)
25
25
  # For other providers, see: https://lobehub.com/docs/self-hosting/environment-variables/auth
26
- LOGTO_CLIENT_ID=YOUR_LOGTO_CLIENT_ID
27
- LOGTO_CLIENT_SECRET=YOUR_LOGTO_CLIENT_SECRET
28
- LOGTO_ISSUER=https://lobe-auth-api.example.com/oidc
26
+ AUTH_LOGTO_CLIENT_ID=YOUR_LOGTO_CLIENT_ID
27
+ AUTH_LOGTO_CLIENT_SECRET=YOUR_LOGTO_CLIENT_SECRET
28
+ AUTH_LOGTO_ISSUER=https://lobe-auth-api.example.com/oidc
29
29
 
30
30
  # Proxy settings (if needed, e.g., when using GitHub as an auth provider)
31
31
  # HTTP_PROXY=http://localhost:7890
@@ -22,9 +22,9 @@ NEXTAUTH_URL=https://lobe.example.com/api/auth
22
22
 
23
23
  # NextAuth 鉴权服务提供商部分,以 Logto 为例
24
24
  # 其他鉴权服务提供商所需的环境变量,请参考:https://lobehub.com/zh/docs/self-hosting/environment-variables/auth
25
- LOGTO_CLIENT_ID=YOUR_LOGTO_CLIENT_ID
26
- LOGTO_CLIENT_SECRET=YOUR_LOGTO_CLIENT_SECRET
27
- LOGTO_ISSUER=https://lobe-auth-api.example.com/oidc
25
+ AUTH_LOGTO_CLIENT_ID=YOUR_LOGTO_CLIENT_ID
26
+ AUTH_LOGTO_CLIENT_SECRET=YOUR_LOGTO_CLIENT_SECRET
27
+ AUTH_LOGTO_ISSUER=https://lobe-auth-api.example.com/oidc
28
28
 
29
29
  # 代理相关,如果你需要的话(比如你使用 GitHub 作为鉴权服务提供商)
30
30
  # HTTP_PROXY=http://localhost:7890
@@ -1,3 +1,4 @@
1
+ name: lobe-chat-database
1
2
  services:
2
3
  postgresql:
3
4
  image: pgvector/pgvector:pg16
@@ -52,7 +53,7 @@ services:
52
53
 
53
54
  lobe:
54
55
  image: lobehub/lobe-chat-database
55
- container_name: lobe-database
56
+ container_name: lobe-chat
56
57
  ports:
57
58
  - '3210:3210'
58
59
  depends_on:
@@ -1,3 +1,4 @@
1
+ name: lobe-chat-database
1
2
  services:
2
3
  postgresql:
3
4
  image: pgvector/pgvector:pg16
@@ -32,14 +33,13 @@ services:
32
33
  restart: always
33
34
  command: >
34
35
  server /etc/minio/data --address ":9000" --console-address ":9001"
35
-
36
+
37
+
36
38
  zitadel:
37
39
  restart: always
38
40
  image: ghcr.io/zitadel/zitadel:latest
39
41
  container_name: lobe-zitadel
40
- command: start-from-init --config /zitadel-config.yaml --steps
41
- /zitadel-init-steps.yaml --masterkey "cft3Tekr/rQBOqwoQSCPoncA9BHbn7QJ"
42
- --tlsMode external #MasterkeyNeedsToHave32Characters
42
+ command: start-from-init --config /zitadel-config.yaml --steps /zitadel-init-steps.yaml --masterkey "cft3Tekr/rQBOqwoQSCPoncA9BHbn7QJ" --tlsMode external #MasterkeyNeedsToHave32Characters
43
43
  ports:
44
44
  - 8080:8080
45
45
  volumes:
@@ -51,7 +51,7 @@ services:
51
51
 
52
52
  lobe:
53
53
  image: lobehub/lobe-chat-database
54
- container_name: lobe-database
54
+ container_name: lobe-chat
55
55
  ports:
56
56
  - '3210:3210'
57
57
  depends_on:
@@ -27,8 +27,8 @@ https://your-domain/api/auth/callback/authentik
27
27
  ```
28
28
 
29
29
  <Callout type={'info'}>
30
- - 可以之后再填写或修改 `重定向 URL/Origin(正则)`,但是务必保证填写的 URL 与部署的 URL 一致。 -
31
- your-domain 请替换为自己的域名
30
+ - 可以之后再填写或修改 `重定向 URL/Origin(正则)`,但是务必保证填写的 URL 与部署的 URL 一致。
31
+ - your-domain 请替换为自己的域名
32
32
  </Callout>
33
33
 
34
34
  <Image
@@ -0,0 +1,120 @@
1
+ ---
2
+ title: Configuring Casdoor Authentication Service in LobeChat
3
+ description: Learn how to configure the Casdoor authentication service in LobeChat, including deployment, creation, permission settings, and environment variables.
4
+ tags:
5
+ - Casdoor Authentication
6
+ - Environment Variable Configuration
7
+ - Single Sign-On
8
+ - LobeChat
9
+ ---
10
+
11
+ # Configuring Casdoor Authentication Service
12
+
13
+ [Casdoor](https://github.com/casdoor/casdoor) is an open-source authentication service that is rich in features and easy to use.
14
+
15
+ <Callout type={'tip'}>
16
+ If you want to privately deploy Casdoor, we recommend using Docker Compose to deploy it together with the LobeChat database version, allowing LobeChat to share the same Postgres instance.
17
+ </Callout>
18
+
19
+ ## Casdoor Configuration Process
20
+
21
+ If you are deploying using a local network IP, the following assumptions apply:
22
+
23
+ - Your LobeChat database version IP/port is `http://LOBECHAT_IP:3210`.
24
+ - You privately deploy Casdoor, and its domain is `http://CASDOOR_IP:8000`.
25
+
26
+ If you are deploying using a public network, the following assumptions apply:
27
+
28
+ - Your LobeChat database version domain is `https://lobe.example.com`.
29
+ - You privately deploy Casdoor, and its domain is `https://lobe-auth-api.example.com`.
30
+
31
+ <Steps>
32
+ ### Create a Casdoor Application
33
+
34
+ Access your privately deployed Casdoor WebUI (default is `http://localhost:8000/`) to enter the console. The default account is `admin`, and the password is `123`.
35
+
36
+ Go to `Authentication` -> `Applications`, create a `LobeChat` application or directly modify the built-in `built-in` application. You can explore other fields, but you must configure at least the following fields:
37
+
38
+ - Name, Display Name: `LobeChat`
39
+ - Redirect URLs:
40
+ - Local Development Environment: `http://localhost:3210/api/auth/callback/casdoor`
41
+ - Local Network IP Deployment: `http://LOBECHAT_IP:3210/api/auth/callback/casdoor`
42
+ - Public Network Environment: `https://lobe.example.com/api/auth/callback/casdoor`
43
+
44
+ There are also some optional fields that can enhance user experience:
45
+
46
+ - Logo: `https://lobehub.com/icon-192x192.png`
47
+ - Form CSS, Form CSS (Mobile):
48
+
49
+ ```html
50
+ <style>
51
+ .login-panel {
52
+ padding: 40px 70px 0 70px;
53
+ border-radius: 10px;
54
+ background-color: #ffffff;
55
+ box-shadow: rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;
56
+ }
57
+ .panel-logo {
58
+ width: 64px;
59
+ }
60
+ .login-logo-box {
61
+ margin-top: 20px;
62
+ }
63
+
64
+ #parent-area
65
+ > main
66
+ > div
67
+ > div.login-content
68
+ > div.login-panel
69
+ > div.login-form
70
+ > div
71
+ > div
72
+ > button {
73
+ box-shadow: none !important;
74
+ border-radius: 10px !important;
75
+ transition-property: all;
76
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
77
+ transition-duration: 150ms;
78
+ border: 1px solid #eee !important;
79
+ }
80
+
81
+ @media (max-width: 640px) {
82
+ .login-panel {
83
+ padding: 40px 0 0 0;
84
+ box-shadow: none;
85
+ }
86
+ }
87
+
88
+ </style>
89
+ ```
90
+
91
+ Then, copy the `Client ID` and `Client Secret` and save them.
92
+
93
+ ### Configure Environment Variables
94
+
95
+ Set the obtained `Client ID` and `Client Secret` as `AUTH_CASDOOR_ID` and `AUTH_CASDOOR_SECRET` in the LobeChat environment variables.
96
+
97
+ Configure `AUTH_CASDOOR_ISSUER` in the LobeChat environment variables as follows:
98
+
99
+ - `http://localhost:8000/` if you are in a local development environment.
100
+ - `http://CASDOOR_IP:8000/` if you are privately deploying Casdoor in a local network.
101
+ - `https://lobe-auth-api.example.com/` if you are deploying Casdoor in a public network environment.
102
+
103
+ When deploying LobeChat, you need to configure the following environment variables:
104
+
105
+ | Environment Variable | Type | Description |
106
+ | --- | --- | --- |
107
+ | `NEXT_AUTH_SECRET` | Required | A key for encrypting Auth.js session tokens. You can generate a key using the command: `openssl rand -base64 32`. |
108
+ | `NEXT_AUTH_SSO_PROVIDERS` | Required | Select the single sign-on provider for LobeChat. Fill in `casdoor` for using Casdoor. |
109
+ | `AUTH_CASDOOR_ID` | Required | The client ID from the Casdoor application details page. |
110
+ | `AUTH_CASDOOR_SECRET` | Required | The client secret from the Casdoor application details page. |
111
+ | `AUTH_CASDOOR_ISSUER` | Required | The OpenID Connect issuer for the Casdoor provider. |
112
+ | `NEXTAUTH_URL` | Required | This URL specifies the callback address for Auth.js during OAuth verification and needs to be set only if the default generated redirect address is incorrect. `https://lobe.example.com/api/auth` |
113
+
114
+ <Callout type={'tip'}>
115
+ Visit [📘 Environment Variables](/docs/self-hosting/environment-variables/auth#casdoor) for details on related variables.
116
+
117
+ </Callout>
118
+ </Steps>
119
+
120
+ <Callout type={'info'}>Once deployed successfully, users will be able to authenticate via Casdoor and use LobeChat.</Callout>
@@ -0,0 +1,121 @@
1
+ ---
2
+ title: 在 LobeChat 中配置 Casdoor 身份验证服务
3
+ description: 学习如何在 LobeChat 中配置 Casdoor 身份验证服务,包括部署、创建、设置权限和环境变量。
4
+ tags:
5
+ - Casdoor 身份验证
6
+ - 环境变量配置
7
+ - 单点登录
8
+ - LobeChat
9
+ ---
10
+
11
+ # 配置 Casdoor 身份验证服务
12
+
13
+ [Casdoor](https://github.com/casdoor/casdoor) 是一个开源的身份验证服务,功能配置丰富且易于上手。
14
+
15
+ <Callout type={'tip'}>
16
+ 若你想要私有部署 Casdoor,我们建议你将之与 LobeChat 数据库版本一同使用 Docker Compose 部署,此时
17
+ LobeChat 可以与之共用同一个 Postgres 实例。
18
+ </Callout>
19
+
20
+ ## Casdoor 配置流程
21
+
22
+ 若你使用局域网 IP 部署,下文假设:
23
+
24
+ - 你的 LobeChat 数据库版本 IP / 端口为 `http://LOBECHAT_IP:3210`。
25
+ - 你私有部署 Casdoor,其域名为 `http://CASDOOR_IP:8000`。
26
+
27
+ 若你使用公网部署,下文假设:
28
+
29
+ - 你的 LobeChat 数据库版本域名为 `https://lobe.example.com`。
30
+ - 你私有部署 Casdoor,其域名为 `https://lobe-auth-api.example.com`。
31
+
32
+ <Steps>
33
+ ### 创建 Casdoor 应用
34
+
35
+ 访问你私有部署的 Casdoor WebUI(默认为 `http://localhost:8000/`) 进入控制台,默认账号为 `admin`,密码为 `123`。
36
+
37
+ 前往 `身份认证` -> `应用`,创建一个 `LobeChat` 应用或直接修改内置的 `built-in` 应用,其他字段可以自行探索,但你至少需要配置以下字段:
38
+
39
+ - 名称、显示名称:`LobeChat`
40
+ - 重定向 URLs:
41
+ - 本地开发环境:`http://localhost:3210/api/auth/callback/casdoor`
42
+ - 局域网 IP 部署:`http://LOBECHAT_IP:3210/api/auth/callback/casdoor`
43
+ - 公网环境:`https://lobe.example.com/api/auth/callback/casdoor`
44
+
45
+ 还有一些不必需但是可以提高用户体验的字段:
46
+
47
+ - Logo:`https://lobehub.com/icon-192x192.png`
48
+ - 表单 CSS、表单 CSS(移动端):
49
+
50
+ ```html
51
+ <style>
52
+ .login-panel {
53
+ padding: 40px 70px 0 70px;
54
+ border-radius: 10px;
55
+ background-color: #ffffff;
56
+ box-shadow: rgba(17, 12, 46, 0.15) 0px 48px 100px 0px;
57
+ }
58
+ .panel-logo {
59
+ width: 64px;
60
+ }
61
+ .login-logo-box {
62
+ margin-top: 20px;
63
+ }
64
+
65
+ #parent-area
66
+ > main
67
+ > div
68
+ > div.login-content
69
+ > div.login-panel
70
+ > div.login-form
71
+ > div
72
+ > div
73
+ > button {
74
+ box-shadow: none !important;
75
+ border-radius: 10px !important;
76
+ transition-property: all;
77
+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
78
+ transition-duration: 150ms;
79
+ border: 1px solid #eee !important;
80
+ }
81
+
82
+ @media (max-width: 640px) {
83
+ .login-panel {
84
+ padding: 40px 0 0 0;
85
+ box-shadow: none;
86
+ }
87
+ }
88
+
89
+ </style>
90
+ ```
91
+
92
+ 随后,复制 `客户端 ID` 和 `客户端密钥`,并保存。
93
+
94
+ ### 配置环境变量
95
+
96
+ 将获取到的 `客户端 ID` 和 `客户端`,设为 LobeChat 环境变量中的 `AUTH_CASDOOR_ID` 和 `AUTH_CASDOOR_SECRET`。
97
+
98
+ 配置 LobeChat 环境变量中 `AUTH_CASDOOR_ISSUER` 为:
99
+
100
+ - `http://localhost:8000/`,若你是本地开发环境
101
+ - `http://CASDOOR_IP:8000/`,若你是局域网私有部署的 Casdoor
102
+ - `https://lobe-auth-api.example.com/`,若你是公网环境部署的 Casdoor
103
+
104
+ 在部署 LobeChat 时,你需要配置以下环境变量:
105
+
106
+ | 环境变量 | 类型 | 描述 |
107
+ | --- | --- | --- |
108
+ | `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
109
+ | `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Casdoor 请填写 `casdoor`。 |
110
+ | `AUTH_CASDOOR_ID` | 必选 | Casdoor 应用详情页的客户端 ID |
111
+ | `AUTH_CASDOOR_SECRET` | 必选 | Casdoor 应用详情页的客户端密钥 |
112
+ | `AUTH_CASDOOR_ISSUER` | 必选 | Casdoor 提供程序的 OpenID Connect 颁发者。 |
113
+ | `NEXTAUTH_URL` | 必选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://lobe.example.com/api/auth` |
114
+
115
+ <Callout type={'tip'}>
116
+ 前往 [📘 环境变量](/zh/docs/self-hosting/environment-variables/auth#casdoor) 可查阅相关变量详情。
117
+
118
+ </Callout>
119
+ </Steps>
120
+
121
+ <Callout type={'info'}>部署成功后,用户将可以通过 Casdoor 身份认证并使用 LobeChat。</Callout>
@@ -49,9 +49,9 @@ tags:
49
49
  | --- | --- | --- |
50
50
  | `NEXT_AUTH_SECRET` | 必选 | 用于加密 Auth.js 会话令牌的密钥。您可以使用以下命令生成秘钥: `openssl rand -base64 32` |
51
51
  | `NEXT_AUTH_SSO_PROVIDERS` | 必选 | 选择 LoboChat 的单点登录提供商。使用 Cloudflare Zero Trust 请填写 `cloudflare-zero-trust`。 |
52
- | `CLOUDFLARE_ZERO_TRUST_CLIENT_ID` | 必选 | 在 Cloudflare Zero Trust 生成的 `Client ID`,示例值是 `lobe-chat` |
53
- | `CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET` | 必选 | 在 Cloudflare Zero Trust 生成的 `Client secret`,示例值是 `insecure_secret` |
54
- | `CLOUDFLARE_ZERO_TRUST_ISSUER` | 必选 | 在 Cloudflare Zero Trust 生成的 `Issuer`,例如 `https://example.cloudflareaccess.com/cdn-cgi/access/sso/oidc/7db0f` |
52
+ | `AUTH_CLOUDFLARE_ZERO_TRUST_CLIENT_ID` | 必选 | 在 Cloudflare Zero Trust 生成的 `Client ID`,示例值是 `lobe-chat` |
53
+ | `AUTH_CLOUDFLARE_ZERO_TRUST_CLIENT_SECRET` | 必选 | 在 Cloudflare Zero Trust 生成的 `Client secret`,示例值是 `insecure_secret` |
54
+ | `AUTH_CLOUDFLARE_ZERO_TRUST_ISSUER` | 必选 | 在 Cloudflare Zero Trust 生成的 `Issuer`,例如 `https://example.cloudflareaccess.com/cdn-cgi/access/sso/oidc/7db0f` |
55
55
  | `NEXTAUTH_URL` | 必选 | 该 URL 用于指定 Auth.js 在执行 OAuth 验证时的回调地址,当默认生成的重定向地址发生不正确时才需要设置。`https://chat.example.com/api/auth` |
56
56
 
57
57
  <Callout type={'tip'}>