feat(env-config): 管理端运行时配置接入-PropertyEnvConfigSource数据源(yh.env-config.source.<target>,target=admin),免登录GET /api/env-config由聚合starter自动装配(旁路CAS),EnvConfigApiIT随机端口匿名200/未配置{}契约(兼平台starter回归哨兵),全量301/301
build / build-push (push) Successful in 1m17s
build / build-push (push) Successful in 1m17s
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.yunhai.cms.config;
|
||||
|
||||
import com.yunhai.platform.envconfig.EnvConfigSource;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* env-config 数据源实现:从 Spring Environment 读取管理端目标的运行时配置 JSON。
|
||||
* 键 = {@code yh.env-config.source.<target>}(管理端 SPA 部署于 /{contextPath}/admin/,target 即 admin),
|
||||
* 三处可配(优先级由 Environment 决定):
|
||||
* 1) 启动参数 --yh.env-config.source.admin='{...}'
|
||||
* 2) 环境变量 YH_ENV_CONFIG_SOURCE_ADMIN(projman .env / Gitea Secrets 注入,宽松绑定)
|
||||
* 3) application.yml 内 yh.env-config.source.admin 键
|
||||
* 未配置返回 null,平台 EnvConfigService 归一为 "{}" 返回(前端走同域推导兜底,接口恒 200)。
|
||||
*
|
||||
* <p>存在本 bean 即满足 {@code yh-env-config-spring-boot-starter} 的自动装配条件(聚合 starter 已携带该模块),
|
||||
* 自动注册免登录 {@code GET /api/env-config?target=admin}:EnvConfigSsoBypassFilter(HIGHEST+3)
|
||||
* 抢在 yh-auth 的 CAS 过滤链(yh.sso.url-pattern=/api/*,HIGHEST+4 起)之前 forward 旁路,SPA 登录前可拉。
|
||||
*/
|
||||
@Service
|
||||
public class PropertyEnvConfigSource implements EnvConfigSource {
|
||||
|
||||
private static final String KEY_PREFIX = "yh.env-config.source.";
|
||||
|
||||
private final Environment environment;
|
||||
|
||||
public PropertyEnvConfigSource(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(String target) {
|
||||
return environment.getProperty(KEY_PREFIX + target);
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,15 @@ yh:
|
||||
base-path: /userbase
|
||||
app-key: 100005
|
||||
app-secret: 2c7885de594742cc840b8762910b2d2e
|
||||
# env-config 管理端运行时配置(免登录 GET /api/env-config?target=admin,数据源见
|
||||
# config/PropertyEnvConfigSource:聚合 starter 自动装配,有 bean 即注册端点)。
|
||||
# 本地无需配值(前端 dev 走 .env.dev);线上值经环境变量 YH_ENV_CONFIG_SOURCE_ADMIN
|
||||
# 或同名键 yh.env-config.source.admin 注入(projman 配置管理维护),未配置时端点返回 {},
|
||||
# 前端走同域推导兜底(serviceHost/baseHost 正确,ssoHost 为空登录跳转不可用)。
|
||||
# 如需本地联调可打开:
|
||||
# env-config:
|
||||
# source:
|
||||
# admin: '{"baseHost":"http://base.yunhaixingtong.com","ssoHost":"http://sso.yunhaixingtong.com","serviceHost":"/yschcms","isMock":false}'
|
||||
|
||||
# ===== CMS 专属配置 =====
|
||||
cms:
|
||||
|
||||
Reference in New Issue
Block a user