micronaut:
application:
name: firmiana
server:
port: 8899 # HTTP 服务器端口
cors:
enabled: true
configurations:
web:
allowed-origins-regex: .* # 警告:生产环境请限制
allowed-methods: [POST, PUT, GET, DELETE, OPTIONS]
allowed-headers: [Content-Type, Authorization, X-Requested-With]
expose-headers: [Content-Type, Authorization]
allow-credentials: false
security:
enabled: true
authentication: bearer
token:
name: Authorization
jwt:
enabled: true # 注意:Matrix 认证使用不透明令牌,非 JWT
signatures:
secret:
default:
secret: ${JWT_SECRET:...}
# Matrix 主服务器设置
matrix:
client:
support:
email-address: admin@localhost
role: m.role.admin
homeserver:
base-url: http://localhost:8899
identity-server:
base-url: http://localhost:8899
identity:
mode: disabled # disabled | embedded | proxy
# 限流
rate-limit:
enabled: true
max-requests-per-window: 100
window-ms: 60000
# H2 数据库
h2:
enabled: true
mode: file
path: ./data/matrix
pool-size: 10
max-lifetime: 1800000
web-console: false
schema-initializer:
enabled: false # 使用 Flyway 替代
# 数据源
datasources:
default:
url: ${DB_URL:jdbc:h2:./data/matrix;DB_CLOSE_DELAY=-1}
driver-class-name: org.h2.Driver
username: ${DB_USERNAME:sa}
password: ${DB_PASSWORD:}
schema-generate: NONE
dialect: H2
# Flyway 迁移
flyway:
datasources:
default:
enabled: true
locations: classpath:db/migration
baseline-on-migrate: true
# 安全头
security-headers:
content-security-policy: "default-src 'self'"
x-content-type-options: nosniff
x-frame-options: DENY
strict-transport-security: "max-age=31536000; includeSubDomains"