保存统一Web域名恢复入口接手基线
Security Checks / security (push) Waiting to run

This commit is contained in:
xuans committed 2026-09-16 19:17:55 +08:00
1 parent 74493f0d5b
commit 606861822b
18 files changed
+129 -90

No files matched your search

+3 -3
View File
@@ -43,13 +43,13 @@ func PublicRecoveryEnabled() bool {
return hasConfiguredRecoveryHost(hosts...)
}
// PublicMailRecoveryEnabled 仅判断主邮件域名下匿名恢复链接入口是否可用。
// PublicMailRecoveryEnabled 仅判断 Web 域名下匿名恢复链接入口是否可用。
// 旧主站恢复流程仍使用 PublicRecoveryEnabled,以保持原有兼容行为。
func PublicMailRecoveryEnabled() bool {
if !config.IsSetupReady() || !config.CurrentEmailPolicy().ExternalRecoveryEnabled {
return false
}
return hasConfiguredRecoveryHost(config.CurrentMailDomains().Primary)
return hasConfiguredRecoveryHost(config.CurrentWebDomain())
}
func hasConfiguredRecoveryHost(values ...string) bool {
@@ -655,7 +655,7 @@ func CompletePasswordRecovery(ctx *context.Context, w http.ResponseWriter, req *
response.NewSuccessResponse(map[string]any{"reset": true}).FPrint(w)
}
// BeginPublicLinkPasswordRecovery 是主邮件域名 /rest/ 的无会话恢复入口。
// BeginPublicLinkPasswordRecovery 是 Web 域名 /rest/ 的无会话恢复入口。
// 所有申请结果统一返回 accepted,避免泄露账户、邮箱绑定和角色状态。
func BeginPublicLinkPasswordRecovery(w http.ResponseWriter, req *http.Request) {
writePublicRecoveryJSON(w, http.StatusOK, map[string]bool{"accepted": true})
@@ -121,7 +121,7 @@ func enablePublicRecoveryForTest(t *testing.T) {
func invokePublicLinkRequirements(t *testing.T, token string) (int, map[string]bool, http.Header) {
t.Helper()
request := httptest.NewRequest(http.MethodPost, "https://mail.example.com/rest/api/recovery/requirements", strings.NewReader(`{"token":"`+token+`"}`))
request := httptest.NewRequest(http.MethodPost, "https://web.example.com/rest/api/recovery/requirements", strings.NewReader(`{"token":"`+token+`"}`))
recorder := httptest.NewRecorder()
PublicLinkPasswordRecoveryRequirements(recorder, request)
result := map[string]bool{}