配置文件详解
配置文件详解
MLiev IAM 使用 config.yaml 作为主配置文件。以下是所有配置项的完整说明。
app — 系统配置
app:
installed: false # 系统是否已完成安装,安装向导完成后自动设为 trueserver — 服务器配置
server:
mode: release # 运行模式:debug(调试)、release(生产)、test(测试)
addr: ":8080" # 监听地址,格式为 :端口 或 IP:端口debug模式会输出详细日志,静态资源从磁盘加载(支持热更新)release模式静态资源从内嵌 FS 加载,适合生产环境
database — 数据库配置
database:
driver: mysql # 驱动:mysql、postgresql、sqlite
halt_on_migration_failure: true # 迁移失败时是否停止启动
# MySQL / PostgreSQL 连接参数
host: localhost
port: 3306
username: root
password: password
database: mliev_iam
charset: utf8mb4 # 仅 MySQL 使用
parse_time: true
loc: Local
# 连接池配置
max_idle_conns: 10 # 最大空闲连接数
max_open_conns: 100 # 最大打开连接数
conn_max_lifetime: 3600 # 连接最大生命周期(秒)
# SQLite 配置(仅 driver 为 sqlite 时使用)
filepath: "./data/mliev_iam.db"PostgreSQL 配置示例
database:
driver: postgresql
host: localhost
port: 5432
username: postgres
password: password
database: mliev_iam
# sslmode: disable # 可选:disable、require、verify-ca、verify-fullredis — Redis 配置
redis:
host: localhost
port: 6379
password: "" # 无密码留空
db: 0 # 数据库编号
pool_size: 10 # 连接池大小
min_idle_conns: 5 # 最小空闲连接数cache — 缓存配置
cache:
driver: memory # 缓存驱动| 驱动 | 说明 |
|---|---|
redis |
使用 Redis 作为缓存后端(需配置 Redis) |
memory |
使用内存缓存(单机部署推荐) |
none |
不使用缓存 |
log — 日志配置
log:
level: info # 日志级别:debug、info、warn、error
filename: logs/app.log # 日志文件路径
max_size: 100 # 单文件最大大小(MB)
max_age: 30 # 日志保留天数
max_backups: 10 # 保留的历史日志文件数
compress: true # 是否压缩历史日志jwt — JWT 配置
jwt:
secret: your-secret-key # JWT 签名密钥(生产环境请使用强随机字符串)
expire_hours: 24 # Token 过期时间(小时)oidc — OIDC 协议配置
oidc:
# 颁发者标识符(必须与外部访问地址一致)
issuer: "http://localhost:8080"
# 令牌生命周期(秒)
token_lifetime:
access_token: 3600 # 访问令牌:1 小时
refresh_token: 2592000 # 刷新令牌:30 天
id_token: 3600 # ID 令牌:1 小时
authorization_code: 600 # 授权码:10 分钟
# 功能开关
features:
pkce_enabled: true # PKCE 支持
introspection_enabled: true # 令牌内省端点
revocation_enabled: true # 令牌撤销端点
refresh_token_enabled: true # 刷新令牌
# 客户端默认值(创建新客户端时的默认配置)
defaults:
scopes: ["openid", "profile", "email"]
grant_types: ["authorization_code", "refresh_token"]
response_types: ["code"]
client_type: "confidential"
# 会话配置
session:
redis_key_prefix: "oidc:session:"
expiration: 600 # 会话过期时间(秒)
# 安全配置
security:
max_authorization_attempts: 5 # 授权码最大尝试次数
max_client_failure_attempts: 10 # 客户端最大失败次数
max_token_refresh_attempts: 100 # 令牌最大刷新次数
rate_limit_enabled: true # 启用速率限制签名密钥说明:每个 OIDC 应用在创建时会自动生成独立的签名密钥(默认 RS256, 2048 位),存储在数据库中。无需手动配置密钥文件。
rate_limit — 限流配置
rate_limit:
requests_per_minute: 100 # 每分钟最大请求数
burst: 10 # 突发请求数cors — 跨域配置
cors:
allow_origins:
- "*" # 允许的来源(生产环境建议指定具体域名)
allow_methods:
- "GET"
- "POST"
- "PUT"
- "DELETE"
- "OPTIONS"
allow_headers:
- "Origin"
- "Content-Type"
- "Authorization"push — 消息推送服务配置
用于发送验证码(短信/邮件):
push:
baseUrl: "https://push.mliev.com" # 推送服务地址
appId: "your_app_id" # 应用 ID
appSecret: "your_app_secret" # 应用密钥
smsChannelId: 1 # 短信通道 ID
emailChannelId: 2 # 邮件通道 ID
smsSignature: "【签名】" # 短信签名