mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 17:24:32 +00:00
fix(gateway): add HSTS header hardening and docs
This commit is contained in:
@@ -189,4 +189,44 @@ describe("resolveGatewayRuntimeConfig", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("HTTP security headers", () => {
|
||||
it("resolves strict transport security header from config", async () => {
|
||||
const result = await resolveGatewayRuntimeConfig({
|
||||
cfg: {
|
||||
gateway: {
|
||||
bind: "loopback",
|
||||
auth: { mode: "none" },
|
||||
http: {
|
||||
securityHeaders: {
|
||||
strictTransportSecurity: " max-age=31536000; includeSubDomains ",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
port: 18789,
|
||||
});
|
||||
|
||||
expect(result.strictTransportSecurityHeader).toBe("max-age=31536000; includeSubDomains");
|
||||
});
|
||||
|
||||
it("does not set strict transport security when explicitly disabled", async () => {
|
||||
const result = await resolveGatewayRuntimeConfig({
|
||||
cfg: {
|
||||
gateway: {
|
||||
bind: "loopback",
|
||||
auth: { mode: "none" },
|
||||
http: {
|
||||
securityHeaders: {
|
||||
strictTransportSecurity: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
port: 18789,
|
||||
});
|
||||
|
||||
expect(result.strictTransportSecurityHeader).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user