2012-05-13 50 views
0

我想知道這是否安全,我不知道記憶是如何工作的。如果我通過忘記註銷,我仍然可以在瀏覽器中查看auth_tkt cookie,所以我認爲它不像加密user_id那樣簡單,並將它們存儲在cookie中,是嗎?
pramid.security.remember安全嗎?

編輯:
我的登錄代碼:

headers = remember(request,user.userId) 
return HTTPFound(location="/",headers=headers) 

註銷代碼:

headers = forget(request) 
return HTTPFound(location="/login",headers=headers) 

回答

1

pyramid.security.remember使用HMAC簽署餅乾這使得它接近防篡改。 http://en.wikipedia.org/wiki/Hmac

關於您關於忘記的問題,您是否將沒有cookie的新請求傳遞給標題?

headers = forget(request) 
return HTTPFound(location = request.route_url('home'), 
       headers = headers) 

http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorials/wiki2/authorization.html#adding-login-and-logout-views

而且它幫助,如果你告訴我們,你已經嘗試了什麼,也許包括你登出視圖代碼

+0

謝謝!如果我註銷,我實際上無法使用該應用,也許Chrome會以某種方式緩存「查看Cookie」頁面。 –

+0

@FelixScheinost如果我沒有錯誤的Chrome瀏覽器呈現所有他們的設置頁面像html網頁會做,所以刷新將需要看看cookies是否改變:) – daniel

+0

哦,我忘了。我很驚訝Chrome不會使用像背景清爽的東西。我還以另一種方式測試了它,同時在兩個不同的瀏覽器中登錄也會生成不同的auth_tkt的 –