|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
HTTP安全头过滤器 更多...
#include <http_security.hpp>
Public 成员函数 | |
| bool | pre_filter (http_request &request, http_response &response) override |
| 预处理方法 | |
| void | post_filter (http_request &request, http_response &response) override |
| 后处理方法 | |
| void | do_filter (http_request &request, http_response &response) override |
| 核心过滤方法 | |
| string | name () const override |
| 获取过滤器名称 | |
Public 属性 | |
| bool | enable_hsts = true |
| HSTS: 强制浏览器使用HTTPS | |
| seconds | hsts_max_age {31536000} |
| 默认1年 | |
| bool | hsts_include_subdomains = true |
| 是否包含子域名 | |
| bool | hsts_preload = false |
| 是否加入HSTS preload列表 | |
| bool | enable_frame_options = true |
| X-Frame-Options: 防止Clickjacking | |
| string | frame_option_value {"DENY"} |
| DENY | SAMEORIGIN | ALLOW-FROM uri | |
| bool | enable_content_type_options = true |
| X-Content-Type-Options: 防止MIME类型嗅探 | |
| bool | enable_csp = true |
| Content-Security-Policy: 内容安全策略 | |
| string | csp_value {"default-src 'self'"} |
| 可配置的CSP策略字符串 | |
| bool | enable_xss_protection = false |
| X-XSS-Protection: 浏览器XSS过滤器 | |
| bool | enable_referrer_policy = true |
| Referrer-Policy: 控制Referer头的发送 | |
| bool | enable_permissions_policy = true |
| Permissions-Policy: 控制浏览器特性权限 | |
HTTP安全头过滤器
自动在所有响应中注入安全相关的HTTP头。 默认启用所有安全头并提供合理默认值,每个header可单独禁用。 在post_filter阶段执行,不阻断请求流程。
在文件 http_security.hpp 第 30 行定义.
|
inlineoverridevirtual |
核心过滤方法
| request | HTTP请求 |
| response | HTTP响应 |
执行实际的过滤逻辑。通常由具体处理器实现, 中间件过滤器可能不实现此方法。
实现了 neforce::http::http_filter.
在文件 http_security.hpp 第 63 行定义.
|
inlinenodiscardoverridevirtual |
|
overridevirtual |
|
inlineoverridevirtual |
预处理方法
| request | HTTP请求 |
| response | HTTP响应 |
在请求处理前调用,可以检查请求、修改请求或提前返回响应。
重载 neforce::http::http_filter .
在文件 http_security.hpp 第 61 行定义.