1
build / build-push (push) Successful in 31s

This commit is contained in:
wanghu
2026-09-03 17:32:05 +08:00
parent a8e02ab176
commit 4d6c07c34c
+5 -7
View File
@@ -89,15 +89,13 @@ namespace YhCore.WebApi
// 对象映射:对应 Java ModelMapper
services.AddAutoMapper(typeof(Startup));
// 对应 Java @CrossOrigin(originPatterns={"*"}, allowCredentials="true"):
// SetIsOriginAllowed(_=>true) 回显请求 Origin(而非 *)+ AllowCredentials,
// 使跨域请求能携带 CAS 登录 Cookie(AllowAnyOrigin 与 AllowCredentials 不能并存,会产生 * + 凭证被浏览器拒绝)。
// 注意:任意源 + 凭证存在 CSRF 风险,上线前按 yh.sso.allow-origins 收紧为白名单。
// 跨域策略:任意源 + 任意方法/头,但不允许凭据(无 AllowCredentials)。
// 响应回 Access-Control-Allow-Origin: *,浏览器跨域请求不携带 CAS 登录 Cookie
// (登录态仅同源请求可用;跨域只能访问免认证接口)。
services.AddCors(options => options.AddPolicy("default", builder => builder
.SetIsOriginAllowed(_ => true)
.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials()));
.AllowAnyHeader()));
// 数据层:默认 SQL Server 主库,DatabaseProvider=MySql 可切换
services.AddDataLayer(Configuration);