Commit 4662c1fe by xiongziliang

cookie过期时间为0时仅限本次访问鉴权

parent a865cccf
...@@ -404,8 +404,8 @@ void installWebHook(){ ...@@ -404,8 +404,8 @@ void installWebHook(){
//执行hook //执行hook
do_http_hook(hook_http_access,body, [invoker](const Value &obj,const string &err){ do_http_hook(hook_http_access,body, [invoker](const Value &obj,const string &err){
if(!err.empty()){ if(!err.empty()){
//如果接口访问失败,那么10秒内该客户端都没有访问http服务器的权限 //如果接口访问失败,那么仅限本次没有访问http服务器的权限
invoker("",10); invoker("",0);
return; return;
} }
//path参数是该客户端能访问的根目录,该目录下的所有文件它都能访问 //path参数是该客户端能访问的根目录,该目录下的所有文件它都能访问
......
...@@ -388,12 +388,16 @@ inline void HttpSession::canAccessPath(const string &path_in,bool is_dir,const f ...@@ -388,12 +388,16 @@ inline void HttpSession::canAccessPath(const string &path_in,bool is_dir,const f
//自己已经销毁 //自己已经销毁
return; return;
} }
//我们给用户生成追踪cookie if(cookieLifeSecond){
auto cookie = CookieManager::Instance().addCookie(uid, kMaxClientPerUid, cookieLifeSecond); //我们给用户生成追踪cookie
//记录用户能访问的路径 auto cookie = CookieManager::Instance().addCookie(uid, kMaxClientPerUid, cookieLifeSecond);
(*cookie)[kAccessPathKey] = accessPath; //记录用户能访问的路径
//判断该用户是否有权限访问该目录,并且设置客户端cookie (*cookie)[kAccessPathKey] = accessPath;
callback(!accessPath.empty() && path.find(accessPath) == 0, cookie); //判断该用户是否有权限访问该目录,并且设置客户端cookie
callback(!accessPath.empty() && path.find(accessPath) == 0, cookie);
}else{
callback(!accessPath.empty() && path.find(accessPath) == 0, nullptr);
}
}); });
}; };
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论