From 4662c1feb02946af44a12744961196387bc4e422 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 13 Jun 2019 09:24:53 +0800 Subject: [PATCH] =?UTF-8?q?cookie=E8=BF=87=E6=9C=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=B8=BA0=E6=97=B6=E4=BB=85=E9=99=90=E6=9C=AC=E6=AC=A1?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=89=B4=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebHook.cpp | 4 ++-- src/Http/HttpSession.cpp | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 93c5654c..f92a5e2e 100644 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -404,8 +404,8 @@ void installWebHook(){ //执行hook do_http_hook(hook_http_access,body, [invoker](const Value &obj,const string &err){ if(!err.empty()){ - //如果接口访问失败,那么10秒内该客户端都没有访问http服务器的权限 - invoker("",10); + //如果接口访问失败,那么仅限本次没有访问http服务器的权限 + invoker("",0); return; } //path参数是该客户端能访问的根目录,该目录下的所有文件它都能访问 diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index fe7ca521..ca714f1f 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -388,12 +388,16 @@ inline void HttpSession::canAccessPath(const string &path_in,bool is_dir,const f //自己已经销毁 return; } - //我们给用户生成追踪cookie - auto cookie = CookieManager::Instance().addCookie(uid, kMaxClientPerUid, cookieLifeSecond); - //记录用户能访问的路径 - (*cookie)[kAccessPathKey] = accessPath; - //判断该用户是否有权限访问该目录,并且设置客户端cookie - callback(!accessPath.empty() && path.find(accessPath) == 0, cookie); + if(cookieLifeSecond){ + //我们给用户生成追踪cookie + auto cookie = CookieManager::Instance().addCookie(uid, kMaxClientPerUid, cookieLifeSecond); + //记录用户能访问的路径 + (*cookie)[kAccessPathKey] = accessPath; + //判断该用户是否有权限访问该目录,并且设置客户端cookie + callback(!accessPath.empty() && path.find(accessPath) == 0, cookie); + }else{ + callback(!accessPath.empty() && path.find(accessPath) == 0, nullptr); + } }); };