支持初始化自定义证书目录并校验写入权限
This commit is contained in:
1 parent
5d5068b20f
commit
77527c293b
11 files changed
+291
-10
No files matched your search
@@ -1,5 +1,6 @@
|
||||
// 首次初始化只提交验证令牌,不接受浏览器指定敏感凭据引用或服务端路径。
|
||||
export function bootstrapPayload(legacy, databaseToken, environment) {
|
||||
// 证书目录是允许自定义的路径例外,由服务端检查目录隔离和写入权限。
|
||||
const notification = {};
|
||||
for (const [key, value] of Object.entries(legacy)) {
|
||||
if (key.startsWith("email_") && key !== "email_http_credential_ref") {
|
||||
@@ -19,6 +20,7 @@ export function bootstrapPayload(legacy, databaseToken, environment) {
|
||||
web_enabled: legacy.web_enabled,
|
||||
https_mode: legacy.https_mode,
|
||||
proxy_https_port: legacy.proxy_https_port,
|
||||
certificate_root: legacy.certificate_root,
|
||||
acme_environment: environment,
|
||||
propagation_timeout_secs: legacy.propagation_timeout_secs,
|
||||
propagation_polling_interval_secs: legacy.propagation_polling_interval_secs,
|
||||
|
||||
@@ -14,7 +14,7 @@ test("初始化只提交服务端验证令牌,通知字段保持兼容且不
|
||||
assert.equal(payload.database_verification_token, "test-database-token");
|
||||
assert.equal(payload.dns_verification_token, "test-dns-token");
|
||||
assert.equal(payload.acme_environment, "staging");
|
||||
assert.equal("certificate_root" in payload, false);
|
||||
assert.equal(payload.certificate_root, "/untrusted");
|
||||
assert.equal("dns_credential_ref" in payload, false);
|
||||
assert.equal("http_credential_ref" in payload.notification, false);
|
||||
assert.deepEqual(payload.notification.http_credentials, { token: "test-notification-token" });
|
||||
|
||||
@@ -758,12 +758,17 @@ const {
|
||||
<legend><span>04</span>证书目录与剩余设置</legend>
|
||||
<div class="setup-grid two-columns">
|
||||
<label>
|
||||
<span>证书部署根目录</span>
|
||||
<span>
|
||||
证书部署根目录
|
||||
<HelpTip>
|
||||
可填写服务器上的绝对路径。Scert 运行账户必须有写入权限;Linux 自定义目录还需位于服务的可写范围内。
|
||||
</HelpTip>
|
||||
</span>
|
||||
<input
|
||||
id="certificate-root"
|
||||
name="certificate_root"
|
||||
v-model.trim="form.certificate_root"
|
||||
:readonly="isBootstrap"
|
||||
maxlength="4096"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -143,7 +143,8 @@ for (const driver of ["sqlite", "mysql", "postgres"]) {
|
||||
for (const key of ["endpoint", "http_auth_mode", "http_credentials", "http_path", "http_headers"]) {
|
||||
assert.equal(Object.hasOwn(submitted[0].notification, key), false);
|
||||
}
|
||||
for (const key of ["dns_credential_ref", "certificate_root", "database", "confirm_password"]) {
|
||||
assert.equal(submitted[0].certificate_root, "/srv/scert/ssl");
|
||||
for (const key of ["dns_credential_ref", "database", "confirm_password"]) {
|
||||
assert.equal(Object.hasOwn(submitted[0], key), false);
|
||||
}
|
||||
assert.equal(Object.hasOwn(submitted[0].notification, "http_credential_ref"), false);
|
||||
@@ -307,6 +308,15 @@ test("bootstrap service port defaults to 80 independently of listener port", asy
|
||||
assert.equal(submitted[0].server_port, 80);
|
||||
});
|
||||
|
||||
test("bootstrap certificate root accepts a custom server path", async (t) => {
|
||||
const { state, submitted } = await setup(t);
|
||||
state.form.value.certificate_root = "/srv/scert/custom-certificates";
|
||||
state.currentStep.value = 4;
|
||||
await state.handleSubmit();
|
||||
assert.equal(state.error.value, "");
|
||||
assert.equal(submitted[0].certificate_root, "/srv/scert/custom-certificates");
|
||||
});
|
||||
|
||||
test("bootstrap service port accepts a custom port", async (t) => {
|
||||
const { state, submitted } = await setup(t);
|
||||
state.form.value.server_port = 8443;
|
||||
|
||||
@@ -22,6 +22,17 @@ function hasClass(name) {
|
||||
&& prop.value?.content.split(/\s+/).includes(name));
|
||||
}
|
||||
|
||||
test("certificate root remains editable during bootstrap", () => {
|
||||
const root = template("./SetupWizard.vue");
|
||||
const input = find(root, (node) => node.props?.some((prop) =>
|
||||
prop.name === "id" && prop.value?.content === "certificate-root"));
|
||||
assert.ok(input);
|
||||
assert.equal(input.props.some((prop) => prop.name === "readonly"
|
||||
|| (prop.name === "bind" && prop.arg?.content === "readonly")), false);
|
||||
assert.ok(input.props.some((prop) => prop.name === "model"
|
||||
&& prop.exp?.content === "form.certificate_root"));
|
||||
});
|
||||
|
||||
test("notification step exposes SMTP only and keeps sender fields in its panel", () => {
|
||||
const root = template("./SetupWizard.vue");
|
||||
const step = find(root, hasClass("setup-notification-step"));
|
||||
|
||||
Reference in new issue
Block a user