Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
SecurityHeaders.hpp
Go to the documentation of this file.
1#pragma once
4#include <chrono>
5#include <string>
6
7namespace orbit::middleware {
8
15 std::chrono::seconds hsts_max_age{std::chrono::hours(24 * 365)};
17 bool hsts_preload = false;
18 bool hsts = true;
19
20 std::string content_type_options = "nosniff";
21 std::string frame_options = "DENY";
22 std::string referrer_policy = "strict-origin-when-cross-origin";
23 std::string cross_origin_opener_policy = "same-origin";
27 std::string permissions_policy;
28};
29
37
38} // namespace middleware
routing::Middleware security_headers(SecurityHeadersOptions options={})
Adds common security response headers (HSTS, nosniff, frame and referrer policies,...
Definition HttpRequest.hpp:19
std::function< bool(http::HttpRequest &, std::shared_ptr< http::ResponseWriter >)> Middleware
Definition Router.hpp:19
Options for security_headers(). An empty string leaves that header out.
Definition SecurityHeaders.hpp:12
std::string referrer_policy
Definition SecurityHeaders.hpp:22
bool hsts_preload
Definition SecurityHeaders.hpp:17
std::chrono::seconds hsts_max_age
Definition SecurityHeaders.hpp:15
std::string frame_options
X-Frame-Options.
Definition SecurityHeaders.hpp:21
bool hsts
Definition SecurityHeaders.hpp:18
std::string content_type_options
Definition SecurityHeaders.hpp:20
std::string content_security_policy
Definition SecurityHeaders.hpp:26
std::string permissions_policy
e.g. "geolocation=(), camera=()"
Definition SecurityHeaders.hpp:27
std::string cross_origin_opener_policy
Definition SecurityHeaders.hpp:23
bool hsts_include_subdomains
Definition SecurityHeaders.hpp:16