Security header middleware collection for Koa applications that wraps Helmet.js
91
Build a Koa application that provides an API for managing cross-domain policy settings for different content types. The application should allow administrators to configure security policies that control whether legacy browser plugins (like Adobe Flash and PDF readers) can load content from the domain.
Policy Configuration Endpoint
/api/policy/configure that accepts a policy settingpolicy field"none", "master-only", "by-content-type", and "all"Policy Status Endpoint
/api/policy/status that returns the currently active policyContent Delivery Endpoints
/content/document that serves a simple text response: "Document content"/content/media that serves a simple text response: "Media content"Default Security
Web framework for Node.js.
Security header middleware for Koa applications.
Router middleware for Koa.
File: server.test.js
Description: Verify that the application starts with the most restrictive cross-domain policy.
Steps:
/content/documentExpected: The response should include an X-Permitted-Cross-Domain-Policies header with value none.
File: server.test.js
Description: Verify that the policy can be changed via the configuration endpoint.
Steps:
/api/policy/configure with body {"policy": "master-only"}/content/documentExpected:
X-Permitted-Cross-Domain-Policies header with value master-onlyFile: server.test.js
Description: Verify that invalid policy values are rejected.
Steps:
/api/policy/configure with body {"policy": "invalid-value"}Expected: The request should return a 400 status code with an error message.
File: server.test.js
Description: Verify that the current policy can be retrieved.
Steps:
/api/policy/configure with body {"policy": "by-content-type"}/api/policy/statusExpected: The status endpoint should return a JSON response containing the current policy: {"policy": "by-content-type"}.
Install with Tessl CLI
npx tessl i tessl/npm-koa-helmetdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10