• 简体中文
  • 应用配置

    Firmiana 通过 src/main/resources/application.yml 进行配置。

    完整配置参考

    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"

    配置段说明

    服务器

    属性默认值说明
    micronaut.server.port8899HTTP 端口
    micronaut.server.cors.enabledtrue启用 CORS
    micronaut.server.cors.configurations.web.allowed-origins-regex.*CORS 来源正则

    安全

    属性默认值说明
    micronaut.security.enabledtrue启用安全
    micronaut.security.authenticationbearer认证方式
    micronaut.security.token.jwt.enabledtrueJWT 集成(不用于 Matrix 认证)

    Matrix

    属性默认值说明
    matrix.homeserver.base-urlhttp://localhost:8899服务器公开 URL
    matrix.identity.modedisabled身份服务模式

    限流

    属性默认值说明
    rate-limit.enabledtrue启用限流
    rate-limit.max-requests-per-window100每窗口最大请求数
    rate-limit.window-ms60000窗口时长(毫秒)

    数据库

    属性默认值说明
    h2.enabledtrue启用 H2
    h2.modefilefilemem
    h2.path./data/matrix数据库文件路径
    h2.pool-size10连接池大小
    flyway.datasources.default.enabledtrue启用 Flyway