Python 普拉米德,安全,记得安全吗?
我想知道这是否安全,我不知道记忆是如何工作的。如果我通过“忘记”注销,我仍然可以在浏览器中查看auth_tkt cookie,因此我认为它不可能像加密用户id并将其存储在cookie中那样简单,是吗?Python 普拉米德,安全,记得安全吗?,python,security,authentication,cookies,pyramid,Python,Security,Authentication,Cookies,Pyramid,我想知道这是否安全,我不知道记忆是如何工作的。如果我通过“忘记”注销,我仍然可以在浏览器中查看auth_tkt cookie,因此我认为它不可能像加密用户id并将其存储在cookie中那样简单,是吗? 编辑: 我的登录代码: headers = remember(request,user.userId) return HTTPFound(location="/",headers=headers) headers = forget(request) return HTTPFound(locati
编辑:
我的登录代码:
headers = remember(request,user.userId)
return HTTPFound(location="/",headers=headers)
headers = forget(request)
return HTTPFound(location="/login",headers=headers)
注销代码:headers = remember(request,user.userId)
return HTTPFound(location="/",headers=headers)
headers = forget(request)
return HTTPFound(location="/login",headers=headers)
记住使用HMAC对cookies进行签名,使其接近防篡改。 关于您关于忘记的问题,您是否在不使用cookie的情况下将新请求传递到标头
headers = forget(request)
return HTTPFound(location = request.route_url('home'),
headers = headers)
如果您向我们展示您的尝试,可能包括您的注销视图代码,也会有所帮助谢谢!如果我注销了,我实际上无法使用该应用程序,也许Chrome会以某种方式缓存“查看cookies”页面。@FelixScheinost如果我没有弄错,Chrome会像网页一样用html呈现所有设置页面,因此需要刷新以查看cookies是否更改:)哦,我忘了。我很惊讶Chrome不会使用背景刷新之类的好东西。我还以另一种方式对其进行了测试,在两个不同的浏览器中登录,同时也会生成不同的auth_tkts@FelixScheinost这是因为HMAC在计算中花费了修改cookie所需的时间,使其更难篡改。您还可以将其设置为记住IP,以便在IP更改时使其无效
authn\u policy=AuthTktAuthenticationPolicy('mysecret',include\u ip=True)
AuthTkt策略实际上不使用HMAC。它使用md5(md5(timestamp+secret+userid+'\0'+令牌+'\0'+userdata)+secret)
。不管怎样,其余的都是真的。它是防篡改的,但不是加密的,这意味着数据对用户是可见的。