@@ -4,64 +4,11 @@ title: 配置
4
4
5
5
配置文件位于 ` backend/core/conf.py ` ,fba 内的所有应用和插件配置都应统一放置在此文件内
6
6
7
- ## 环境变量配置
7
+ ## 环境配置
8
8
9
- ### ` ENVIRONMENT ` <Badge type =" info " text =" Literal['dev', 'pro'] " />
9
+ ### ` ENVIRONMENT ` <Badge type =" info " text =" Literal['dev', 'pro'] " /> < Badge type = " warning " text = " env " />
10
10
11
- 指定环境模式,仅允许 ` dev ` 和 ` pro ` 。当设置为 ` pro ` 时,openapi 相关在线文档将被禁止访问
12
-
13
- ### ` DATABASE_TYPE ` <Badge type =" info " text =" Literal['mysql', 'postgresql'] " />
14
-
15
- 指定数据库类型,仅支持 ` mysql ` 和 ` postgresql ` ,需注意第三方插件兼容性
16
-
17
- ### ` DATABASE_HOST ` <Badge type =" info " text =" str " />
18
-
19
- 提供数据库的主机地址
20
-
21
- ### ` DATABASE_PORT ` <Badge type =" info " text =" int " />
22
-
23
- 提供数据库的主机端口号
24
-
25
- ### ` DATABASE_USER ` <Badge type =" info " text =" str " />
26
-
27
- 连接数据库所使用的用户名
28
-
29
- ### ` DATABASE_PASSWORD ` <Badge type =" info " text =" str " />
30
-
31
- 连接数据库所使用的密码
32
-
33
- ### ` REDIS_HOST ` <Badge type =" info " text =" int " />
34
-
35
- 连接 Redis 数据库的主机地址
36
-
37
- ### ` REDIS_PORT ` <Badge type =" info " text =" str " />
38
-
39
- 连接 Redis 数据库的主机端口号
40
-
41
- ### ` REDIS_PASSWORD ` <Badge type =" info " text =" int " />
42
-
43
- 连接 Redis 数据库的密码
44
-
45
- ### ` REDIS_DATABASE ` <Badge type =" info " text =" str " />
46
-
47
- 全局默认使用的 Redis 逻辑数据库(0 - 15)
48
-
49
- ### ` TOKEN_SECRET_KEY ` <Badge type =" info " text =" str " />
50
-
51
- token 生成和解析密钥,用于防止 token 被恶意篡改,密钥生成:` secrets.token_urlsafe(32) `
52
-
53
- ::: danger
54
- 请妥善保管此值,以免遭受恶意攻击
55
- :::
56
-
57
- ### ` OPERA_LOG_ENCRYPT_SECRET_KEY ` <Badge type =" info " text =" " />
58
-
59
- 操作日志加密密钥,当使用对称加密算法加密操作日志时,将十分重要,密钥生成:
60
- ` os.urandom(32).hex() `
61
-
62
- ::: danger
63
- 请妥善保管此值,以免遭受恶意攻击
64
- :::
11
+ 指定环境模式,当设置为 ` pro ` 时,openapi 相关在线文档将被禁止访问
65
12
66
13
## FastAPI 配置
67
14
@@ -97,7 +44,27 @@ openapi JSON 数据在线地址
97
44
98
45
是否开启 FastAPI 静态文件服务
99
46
100
- ## 数据库基础配置
47
+ ## 数据库配置
48
+
49
+ ### ` DATABASE_TYPE ` <Badge type =" info " text =" Literal['mysql', 'postgresql'] " /> <Badge type =" warning " text =" env " />
50
+
51
+ 指定数据库类型,仅支持 ` mysql ` 和 ` postgresql ` ,需注意第三方插件兼容性
52
+
53
+ ### ` DATABASE_HOST ` <Badge type =" info " text =" str " /> <Badge type =" warning " text =" env " />
54
+
55
+ 提供数据库的主机地址
56
+
57
+ ### ` DATABASE_PORT ` <Badge type =" info " text =" int " /> <Badge type =" warning " text =" env " />
58
+
59
+ 提供数据库的主机端口号
60
+
61
+ ### ` DATABASE_USER ` <Badge type =" info " text =" str " /> <Badge type =" warning " text =" env " />
62
+
63
+ 连接数据库所使用的用户名
64
+
65
+ ### ` DATABASE_PASSWORD ` <Badge type =" info " text =" str " /> <Badge type =" warning " text =" env " />
66
+
67
+ 连接数据库所使用的密码
101
68
102
69
### ` DATABASE_ECHO ` <Badge type =" info " text =" bool | Literal['debug'] " />
103
70
@@ -115,25 +82,49 @@ openapi JSON 数据在线地址
115
82
116
83
数据库字符集,仅用于 mysql
117
84
118
- ## Redis 基础配置
85
+ ## Redis 配置
119
86
120
- ### ` REDIS_TIMEOUT ` <Badge type =" info " text =" int " />
87
+ ### ` REDIS_TIMEOUT ` <Badge type =" info " text =" int " /> < Badge type = " warning " text = " env " />
121
88
122
89
连接 Redis 数据库超时时长
123
90
124
- ## Token 基础配置
91
+ ### ` REDIS_HOST ` <Badge type =" info " text =" int " />
92
+
93
+ 连接 Redis 数据库的主机地址
94
+
95
+ ### ` REDIS_PORT ` <Badge type =" info " text =" str " />
96
+
97
+ 连接 Redis 数据库的主机端口号
98
+
99
+ ### ` REDIS_PASSWORD ` <Badge type =" info " text =" int " />
100
+
101
+ 连接 Redis 数据库的密码
102
+
103
+ ### ` REDIS_DATABASE ` <Badge type =" info " text =" str " />
104
+
105
+ 全局默认使用的 Redis 逻辑数据库(0 - 15)
106
+
107
+ ## Token 配置
108
+
109
+ ### ` TOKEN_SECRET_KEY ` <Badge type =" info " text =" str " /> <Badge type =" warning " text =" env " />
110
+
111
+ token 生成和解析密钥,用于防止 token 被恶意篡改,密钥生成:` secrets.token_urlsafe(32) `
112
+
113
+ ::: danger
114
+ 请妥善保管此值,以免遭受恶意攻击
115
+ :::
125
116
126
117
### ` TOKEN_ALGORITHM ` <Badge type =" info " text =" str " />
127
118
128
119
token 加密算法
129
120
130
121
### ` TOKEN_EXPIRE_SECONDS ` <Badge type =" info " text =" int " />
131
122
132
- token 过期秒数
123
+ token 过期时长
133
124
134
125
### ` TOKEN_REFRESH_EXPIRE_SECONDS ` <Badge type =" info " text =" int " />
135
126
136
- 刷新 token 过期秒数
127
+ 刷新 token 过期时长
137
128
138
129
### ` TOKEN_REDIS_PREFIX ` <Badge type =" info " text =" str " />
139
130
@@ -190,7 +181,17 @@ JWT 中间件存储用户信息到 Redis 时的前缀
190
181
191
182
### ` COOKIE_REFRESH_TOKEN_EXPIRE_SECONDS ` <Badge type =" info " text =" int " />
192
183
193
- 将刷新 token 存储到 cookie 时的过期时间
184
+ 将刷新 token 存储到 cookie 时的过期时长
185
+
186
+ ## 验证码配置
187
+
188
+ ### ` CAPTCHA_LOGIN_REDIS_PREFIX ` <Badge type =" info " text =" str " />
189
+
190
+ 验证码登录时,验证码存储到 Redis 时的前缀
191
+
192
+ ### ` CAPTCHA_LOGIN_EXPIRE_SECONDS ` <Badge type =" info " text =" int " />
193
+
194
+ 验证码登录时,验证码过期时长
194
195
195
196
## 数据权限配置
196
197
@@ -342,6 +343,15 @@ JWT 中间件存储用户信息到 Redis 时的前缀
342
343
343
344
## 操作日志
344
345
346
+ ### ` OPERA_LOG_ENCRYPT_SECRET_KEY ` <Badge type =" info " text =" str " /> <Badge type =" warning " text =" env " />
347
+
348
+ 操作日志加密密钥,当使用对称加密算法加密操作日志时,将十分重要,密钥生成:
349
+ ` os.urandom(32).hex() `
350
+
351
+ ::: danger
352
+ 请妥善保管此值,以免遭受恶意攻击
353
+ :::
354
+
345
355
### ` OPERA_LOG_PATH_EXCLUDE ` <Badge type =" info " text =" list[str] " />
346
356
347
357
操作日志路径排除,在此配置内的请求地址不会记录操作日志
@@ -382,84 +392,94 @@ JWT 中间件存储用户信息到 Redis 时的前缀
382
392
383
393
插件信息存储到 Redis 时的前缀
384
394
385
- ## 验证码配置
386
-
387
- ### ` CAPTCHA_LOGIN_REDIS_PREFIX ` <Badge type =" info " text =" str " />
388
-
389
- 验证码登录时,验证码存储到 Redis 时的前缀
390
-
391
- ### ` CAPTCHA_LOGIN_EXPIRE_SECONDS ` <Badge type =" info " text =" int " />
392
-
393
- 验证码登录时,验证码过期时间
394
-
395
395
## 应用:Task
396
396
397
- ### 环境变量配置
398
-
399
- #### ` CELERY_BROKER_REDIS_DATABASE ` <Badge type =" info " text =" int " />
397
+ ### ` CELERY_BROKER_REDIS_DATABASE ` <Badge type =" info " text =" int " /> <Badge type =" warning " text =" env " />
400
398
401
399
Celery 代理使用的 Redis 逻辑数据库
402
400
403
- #### ` CELERY_RABBITMQ_HOST ` <Badge type =" info " text =" str " />
401
+ ### ` CELERY_RABBITMQ_HOST ` <Badge type =" info " text =" str " /> < Badge type = " warning " text = " env " />
404
402
405
403
Celery 连接 RabbitMQ 服务的主机地址
406
404
407
- #### ` CELERY_RABBITMQ_PORT ` <Badge type =" info " text =" int " />
405
+ ### ` CELERY_RABBITMQ_PORT ` <Badge type =" info " text =" int " /> < Badge type = " warning " text = " env " />
408
406
409
407
Celery 连接 RabbitMQ 服务的主机端口号
410
408
411
- #### ` CELERY_RABBITMQ_USERNAME ` <Badge type =" info " text =" str " />
409
+ ### ` CELERY_RABBITMQ_USERNAME ` <Badge type =" info " text =" str " /> < Badge type = " warning " text = " env " />
412
410
413
411
Celery 连接 RabbitMQ 服务的用户名
414
412
415
- #### ` CELERY_RABBITMQ_PASSWORD ` <Badge type =" info " text =" str " />
413
+ ### ` CELERY_RABBITMQ_PASSWORD ` <Badge type =" info " text =" str " /> < Badge type = " warning " text = " env " />
416
414
417
415
Celery 连接 RabbitMQ 服务的密码
418
416
419
- ### 基础配置
420
-
421
- #### ` CELERY_BROKER ` <Badge type =" info " text =" Literal['rabbitmq', 'redis'] " />
417
+ ### ` CELERY_BROKER ` <Badge type =" info " text =" Literal['rabbitmq', 'redis'] " />
422
418
423
419
Celery 代理模式(开发模式默认使用 Redis,线上模式强制切换为 Rabbitmq)
424
420
425
- #### ` CELERY_REDIS_PREFIX ` <Badge type =" info " text =" str " />
421
+ ### ` CELERY_REDIS_PREFIX ` <Badge type =" info " text =" str " />
426
422
427
423
Celery 数据存储到 Redis 时的前缀
428
424
429
- #### ` CELERY_TASK_MAX_RETRIES ` <Badge type =" info " text =" int " />
425
+ ### ` CELERY_TASK_MAX_RETRIES ` <Badge type =" info " text =" int " />
430
426
431
427
Celery 任务执行失败时的最大重试次数
432
428
433
- ## 插件:OAuth2
429
+ ## 插件:Code Generator
434
430
435
- ### 环境变量配置
431
+ #### ` CODE_GENERATOR_DOWNLOAD_ZIP_FILENAME ` <Badge type =" info " text =" str " />
432
+
433
+ 下载代码时的 ZIP 压缩包文件名
436
434
437
- #### ` OAUTH2_GITHUB_CLIENT_ID ` <Badge type =" info " text =" str " />
435
+ ## 插件:OAuth2
436
+
437
+ ### ` OAUTH2_GITHUB_CLIENT_ID ` <Badge type =" info " text =" str " /> <Badge type =" warning " text =" env " />
438
438
439
439
GitHub 客户端 ID
440
440
441
- #### ` OAUTH2_GITHUB_CLIENT_SECRET ` <Badge type =" info " text =" str " />
441
+ ### ` OAUTH2_GITHUB_CLIENT_SECRET ` <Badge type =" info " text =" str " /> < Badge type = " warning " text = " env " />
442
442
443
443
GitHub 客户端密钥
444
444
445
- #### ` OAUTH2_LINUX_DO_CLIENT_ID ` <Badge type =" info " text =" str " />
445
+ ### ` OAUTH2_LINUX_DO_CLIENT_ID ` <Badge type =" info " text =" str " /> < Badge type = " warning " text = " env " />
446
446
447
447
Linux Do 客户端 ID
448
448
449
- #### ` OAUTH2_LINUX_DO_CLIENT_SECRET ` <Badge type =" info " text =" str " />
449
+ ### ` OAUTH2_LINUX_DO_CLIENT_SECRET ` <Badge type =" info " text =" str " /> < Badge type = " warning " text = " env " />
450
450
451
451
Linux Do 客户端密钥
452
452
453
- ### 基础配置
454
-
455
- #### ` OAUTH2_FRONTEND_REDIRECT_URI ` <Badge type =" info " text =" str " />
453
+ ### ` OAUTH2_FRONTEND_REDIRECT_URI ` <Badge type =" info " text =" str " />
456
454
457
455
登陆成功后,重定向到前端的地址
458
456
459
- ## 插件:Code Generator
457
+ ## 插件:Email
460
458
461
- ### 基础配置
459
+ ### ` EMAIL_USERNAME ` < Badge type = " info " text = " str " />
462
460
463
- #### ` CODE_GENERATOR_DOWNLOAD_ZIP_FILENAME ` < Badge type = " info " text = " str " />
461
+ 电子邮箱发件用户
464
462
465
- 下载代码时的 ZIP 压缩包文件名
463
+ ### ` EMAIL_PASSWORD ` <Badge type =" info " text =" str " />
464
+
465
+ 电子邮箱发件用户密码
466
+
467
+ ### ` EMAIL_HOST ` <Badge type =" info " text =" str " />
468
+
469
+ 电子邮箱服务主机地址
470
+
471
+ ### ` EMAIL_PORT ` <Badge type =" info " text =" int " />
472
+
473
+ 电子邮箱服务主机端口号
474
+
475
+ ### ` EMAIL_SSL ` <Badge type =" info " text =" bool " />
476
+
477
+ 发送电子邮件时,是否开启 SSL
478
+
479
+ ### ` EMAIL_CAPTCHA_REDIS_PREFIX ` <Badge type =" info " text =" str " />
480
+
481
+ 电子邮件验证码存储到 Redis 时的前缀
482
+
483
+ ### ` EMAIL_CAPTCHA_EXPIRE_SECONDS ` <Badge type =" info " text =" int " />
484
+
485
+ 电子邮件验证码缓存时长
0 commit comments