fix(U4): pms-auth application-{env}.yml 环境拆分——dev/prod profile 隔离

- application.yml 保留公共配置,profiles.active 改为 env var 控制

- application-dev.yml: debug 日志 + captcha.debug=true + token 有 dev 默认值

- application-prod.yml: info 日志 + captcha.debug=false + INTERNAL_API_TOKEN 无默认值(fail-fast)

- application-prod.yml 仅含占位符无明文密钥,force-add 绕过 .gitignore

- 模板可复用于其他 7 个服务
This commit is contained in:
ether 2026-07-04 22:53:48 +08:00
parent 14d61346e4
commit b28a5fbde4
3 changed files with 34 additions and 11 deletions

View File

@ -0,0 +1,15 @@
# 开发环境配置
# 启动方式SPRING_PROFILES_ACTIVE=dev或不设默认 dev
logging:
level:
com.pms: debug
# 验证码调试模式E2E 测试时跳过验证码校验
captcha:
debug: true
# 内部接口鉴权dev 环境提供默认 token方便本地联调
internal:
api:
token: ${INTERNAL_API_TOKEN:dev-internal-token}

View File

@ -0,0 +1,17 @@
# 生产环境配置
# 启动方式SPRING_PROFILES_ACTIVE=prod
# 注意INTERNAL_API_TOKEN 必须通过环境变量提供缺失则启动失败fail-fast
logging:
level:
com.pms: info
# 验证码调试模式:生产环境必须关闭
captcha:
debug: false
# 内部接口鉴权prod 环境无默认 token必须通过环境变量注入
internal:
api:
token: ${INTERNAL_API_TOKEN}
enforce: true

View File

@ -4,8 +4,9 @@ server:
spring:
application:
name: auth-service
# 通过环境变量指定 profile默认 dev
profiles:
active: dev
active: ${SPRING_PROFILES_ACTIVE:dev}
# 数据源
datasource:
url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/auth_db?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
@ -85,10 +86,6 @@ mybatis-plus:
map-underscore-to-camel-case: true
cache-enabled: false
# 验证码调试模式E2E测试时设为true生产环境必须为false
captcha:
debug: false
# JWT 配置(认证服务持有私钥用于签发)
jwt:
algorithm: RS256
@ -102,7 +99,6 @@ jwt:
# 内部接口鉴权配置U9
internal:
api:
token: ${INTERNAL_API_TOKEN:dev-internal-token}
enforce: ${INTERNAL_API_ENFORCE:true}
# Resilience4j 熔断配置U17复用 pms-base 配置)
@ -125,11 +121,6 @@ resilience4j:
default:
timeout-duration: 6s
# 日志
logging:
level:
com.pms: debug # 生产环境应设为 info
# 端点暴露U7KTD7 安全白名单,仅 health 与 prometheus
management:
endpoints: