NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
载入中...
搜索中...
未找到
neforce::http::authentication_filter类 参考final

认证过滤器 更多...

#include <http_filter.hpp>

类 neforce::http::authentication_filter 继承关系图:
[图例]

Public 成员函数

 authentication_filter (function< bool(const http_request &)> validator)
 构造函数
void set_auth_validator (function< bool(const http_request &)> validator)
 设置认证验证器
void add_excluded_path (string path)
 添加排除路径(不要求认证)
void add_included_path (string path)
 添加受保护路径(要求认证)
void clear_excluded_paths ()
 清除所有排除路径
void clear_included_paths ()
 清除所有包含路径
bool pre_filter (http_request &request, http_response &response) override
 预处理方法
void do_filter (http_request &request, http_response &response) override
 核心过滤方法
string name () const override
 获取过滤器名称
Public 成员函数 继承自 neforce::http::http_filter
virtual void post_filter (http_request &request, http_response &response)
 后处理方法

详细描述

认证过滤器

验证请求是否包含有效的认证信息。

在文件 http_filter.hpp327 行定义.

构造及析构函数说明

◆ authentication_filter()

neforce::http::authentication_filter::authentication_filter ( function< bool(const http_request &)> validator)
inlineexplicit

构造函数

参数
validator认证验证函数

在文件 http_filter.hpp343 行定义.

引用了 neforce::move().

成员函数说明

◆ add_excluded_path()

void neforce::http::authentication_filter::add_excluded_path ( string path)
inline

添加排除路径(不要求认证)

参数
path路径(支持前缀匹配)

仅在 included_paths_ 为空时生效(全量认证模式)。

在文件 http_filter.hpp360 行定义.

引用了 neforce::move().

◆ add_included_path()

void neforce::http::authentication_filter::add_included_path ( string path)
inline

添加受保护路径(要求认证)

参数
path路径(支持前缀匹配)

设置后仅这些路径需要认证,其余路径为公开访问。

在文件 http_filter.hpp368 行定义.

引用了 neforce::move().

◆ do_filter()

void neforce::http::authentication_filter::do_filter ( http_request & request,
http_response & response )
inlineoverridevirtual

核心过滤方法

参数
requestHTTP请求
responseHTTP响应

执行实际的过滤逻辑。通常由具体处理器实现, 中间件过滤器可能不实现此方法。

实现了 neforce::http::http_filter.

在文件 http_filter.hpp381 行定义.

◆ name()

string neforce::http::authentication_filter::name ( ) const
inlinenodiscardoverridevirtual

获取过滤器名称

返回
过滤器名称

重载 neforce::http::http_filter .

在文件 http_filter.hpp382 行定义.

◆ pre_filter()

bool neforce::http::authentication_filter::pre_filter ( http_request & request,
http_response & response )
overridevirtual

预处理方法

参数
requestHTTP请求
responseHTTP响应
返回
返回false表示中断后续处理

在请求处理前调用,可以检查请求、修改请求或提前返回响应。

重载 neforce::http::http_filter .

◆ set_auth_validator()

void neforce::http::authentication_filter::set_auth_validator ( function< bool(const http_request &)> validator)
inline

设置认证验证器

参数
validator验证函数

在文件 http_filter.hpp350 行定义.

引用了 neforce::move().


该类的文档由以下文件生成: