NexusForce
1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
http_security.hpp
浏览该文件的文档.
1
#ifndef NEFORCE_NETWORK_HTTP_HTTP_SECURITY_HPP__
2
#define NEFORCE_NETWORK_HTTP_HTTP_SECURITY_HPP__
3
12
13
#include "
NeForce/network/http/http_filter.hpp
"
14
NEFORCE_BEGIN_NAMESPACE__
15
NEFORCE_BEGIN_HTTP__
16
21
30
class
NEFORCE_API
security_headers_filter
final :
public
http_filter
{
31
public
:
33
bool
enable_hsts
=
true
;
34
seconds
hsts_max_age
{31536000};
35
bool
hsts_include_subdomains
=
true
;
36
bool
hsts_preload
=
false
;
37
39
bool
enable_frame_options
=
true
;
40
string
frame_option_value
{
"DENY"
};
41
43
bool
enable_content_type_options
=
true
;
44
46
bool
enable_csp
=
true
;
47
string
csp_value
{
"default-src 'self'"
};
48
50
bool
enable_xss_protection
=
false
;
51
string
xss_protection_value{
"1; mode=block"
};
52
54
bool
enable_referrer_policy
=
true
;
55
string
referrer_policy_value{
"strict-origin-when-cross-origin"
};
56
58
bool
enable_permissions_policy
=
true
;
59
string
permissions_policy_value{
"geolocation=(), microphone=(), camera=()"
};
60
61
bool
pre_filter
(
http_request
& request,
http_response
& response)
override
{
return
true
; }
62
void
post_filter
(
http_request
& request,
http_response
& response)
override
;
63
void
do_filter
(
http_request
& request,
http_response
& response)
override
{}
64
NEFORCE_NODISCARD
string
name
()
const override
{
return
"security_headers_filter"
; }
65
};
66
67
// TODO: OAuth2 / OIDC authentication filter — implement Authorization Code, Client Credentials, PKCE flows with token validation
68
// TODO: JWT token filter — parse, validate (exp/nbf/iss/aud), and extract claims from Bearer tokens; support JWKS key rotation
69
// TODO: Role-based access control (RBAC) filter — @PreAuthorize-style method/route-level role & permission checking
70
// TODO: Password encoding utilities — BCrypt, Argon2id, PBKDF2 hashing with salt generation and constant-time verification
71
// HTTP
73
74
NEFORCE_END_HTTP__
75
NEFORCE_END_NAMESPACE__
76
#endif
// NEFORCE_NETWORK_HTTP_HTTP_SECURITY_HPP__
neforce::http::http_filter
HTTP过滤器基类
定义
http_filter.hpp:48
neforce::http::security_headers_filter
HTTP安全头过滤器
定义
http_security.hpp:30
neforce::http::security_headers_filter::enable_xss_protection
bool enable_xss_protection
X-XSS-Protection: 浏览器XSS过滤器
定义
http_security.hpp:50
neforce::http::security_headers_filter::do_filter
void do_filter(http_request &request, http_response &response) override
核心过滤方法
定义
http_security.hpp:63
neforce::http::security_headers_filter::enable_frame_options
bool enable_frame_options
X-Frame-Options: 防止Clickjacking
定义
http_security.hpp:39
neforce::http::security_headers_filter::name
string name() const override
获取过滤器名称
定义
http_security.hpp:64
neforce::http::security_headers_filter::enable_referrer_policy
bool enable_referrer_policy
Referrer-Policy: 控制Referer头的发送
定义
http_security.hpp:54
neforce::http::security_headers_filter::enable_content_type_options
bool enable_content_type_options
X-Content-Type-Options: 防止MIME类型嗅探
定义
http_security.hpp:43
neforce::http::security_headers_filter::frame_option_value
string frame_option_value
DENY | SAMEORIGIN | ALLOW-FROM uri
定义
http_security.hpp:40
neforce::http::security_headers_filter::hsts_preload
bool hsts_preload
是否加入HSTS preload列表
定义
http_security.hpp:36
neforce::http::security_headers_filter::enable_hsts
bool enable_hsts
HSTS: 强制浏览器使用HTTPS
定义
http_security.hpp:33
neforce::http::security_headers_filter::enable_csp
bool enable_csp
Content-Security-Policy: 内容安全策略
定义
http_security.hpp:46
neforce::http::security_headers_filter::enable_permissions_policy
bool enable_permissions_policy
Permissions-Policy: 控制浏览器特性权限
定义
http_security.hpp:58
neforce::http::security_headers_filter::post_filter
void post_filter(http_request &request, http_response &response) override
后处理方法
neforce::http::security_headers_filter::hsts_max_age
seconds hsts_max_age
默认1年
定义
http_security.hpp:34
neforce::http::security_headers_filter::csp_value
string csp_value
可配置的CSP策略字符串
定义
http_security.hpp:47
neforce::http::security_headers_filter::hsts_include_subdomains
bool hsts_include_subdomains
是否包含子域名
定义
http_security.hpp:35
neforce::http::security_headers_filter::pre_filter
bool pre_filter(http_request &request, http_response &response) override
预处理方法
定义
http_security.hpp:61
neforce::seconds
duration< int64_t > seconds
秒持续时间
定义
duration.hpp:158
neforce::http::http_response
http_server_response http_response
HTTP响应类型别名
定义
http_server_message.hpp:369
neforce::http::http_request
http_server_request http_request
HTTP请求类型别名
定义
http_server_message.hpp:363
http_filter.hpp
HTTP过滤器链实现
include
NeForce
network
http
http_security.hpp
制作者
1.16.0