blob: bcaa87dddb67b627b4ba3a361a280445d2ca8210 [file] [log] [blame]
Ed Tanous8041f312017-04-03 09:47:01 -07001#include <security_headers_middleware.hpp>
2
3namespace crow {
4
5void SecurityHeadersMiddleware::before_handle(crow::request& req, response& res,
6 context& ctx) {}
7
8void SecurityHeadersMiddleware::after_handle(request& /*req*/, response& res,
9 context& ctx) {
10 // TODO(ed) these should really check content types. for example, X-UA-Compatible
11 // header doesn't make sense when retrieving a JSON or javascript file. It doesn't
12 // hurt anything, it's just ugly.
13 res.set_header("Strict-Transport-Security",
14 "max-age=31536000; includeSubdomains; preload");
15 res.set_header("X-UA-Compatible", "IE=11");
16 res.set_header("X-Frame-Options", "DENY");
17 res.set_header("X-XSS-Protection", "1; mode=block");
18 res.set_header("X-Content-Security-Policy", "default-src 'self'");
19}
20}