fix(storage): presigned URL 改用对外可达 host,修复客户端直传断链
SeaweedFS 换存储后 MINIO_ENDPOINT 变为 seaweedfs:8333(容器名), PhotoService 生成的 presigned URL 把该 host 直接下发给客户端, 客户端不在 docker 网络内无法解析 → 直传/直链全断。 - S3Config:新增 amazonS3Signer Bean,指向 object-storage.public-endpoint (缺省回退内网 endpoint,向后兼容)。独立签名端是因为 SigV4 签名覆盖 host 头,事后改 URL 字符串会让签名失效返 403;独立客户端让签名 host 与客户端实际命中的 host 天然一致。 - PhotoService:去掉 @RequiredArgsConstructor,改显式 @Qualifier 构造器; getUploadToken / getSignedUrl / getSignedUrlForAuthorizedReview 三处 presigned 生成改用 amazonS3Signer;putObject 服务端上传仍走内网 amazonS3。 - application-docker.yml / application-dev.yml:public-endpoint 读 MINIO_PUBLIC_ENDPOINT(缺省回退 MINIO_ENDPOINT)。 - 三套 compose:注入 MINIO_PUBLIC_ENDPOINT (dev localhost:8333 / staging localhost:8334 / prod 留作单一旋钮)。 - 测试:PhotoServiceTest 新增嵌套 PresignedUrlPublicHostTest,用真实 AmazonS3 客户端(仅本地签名不联网)断言下发 URL host 为对外地址、 不含 seaweedfs 容器名;同步补齐两处 5→6 参构造调用。 验证:本机 65 E2E 全绿 + storage_link_probe path-style 全通 + PhotoServiceTest/PhotoUploadValidationTest/PhotoLimitGuardTest 19 例单测全绿。 顺带:backend/maven-settings.xml 的 Central 兜底由投毒的 repo1.maven.org 改为可达的 repo.maven.apache.org,使本机镜像构建可走 aliyun 主源。
This commit is contained in:
@@ -1,11 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
|
||||
<mirrors>
|
||||
<mirror>
|
||||
<id>central</id>
|
||||
<mirrorOf>central</mirrorOf>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo1.maven.org/maven2</url>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
<!--
|
||||
本地构建必须走 aliyun 镜像:本机 Maven Central(repo1.maven.org)被 DNS 投毒,
|
||||
TLS 握手被中断("Remote host terminated the handshake"),直连 central 必然失败。
|
||||
aliyun 作为主源、central 作为兜底(仅当 aliyun 缺失某构件时才回退,正常构件不会触达 central)。
|
||||
CI runner 能直连 central,但 aliyun 同样可达,故该配置对 CI 也无害。
|
||||
-->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>aliyun-with-central-fallback</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>aliyun-public</id>
|
||||
<name>Aliyun Public</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Maven Central</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>aliyun-plugin-public</id>
|
||||
<name>Aliyun Plugin Public</name>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>central-plugin</id>
|
||||
<name>Maven Central Plugins</name>
|
||||
<url>https://repo.maven.apache.org/maven2</url>
|
||||
<releases><enabled>true</enabled></releases>
|
||||
<snapshots><enabled>false</enabled></snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
<activeProfiles>
|
||||
<activeProfile>aliyun-with-central-fallback</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
||||
|
||||
Reference in New Issue
Block a user