actix_login icon indicating copy to clipboard operation
actix_login copied to clipboard

Why can I keep updating password even after logout?

Open yjiangnan opened this issue 3 years ago • 0 comments

Hi, I almost copied your code to build a server. I can register users, and login only if the password is correct. Then I receive the authentication cookie. However, when I use the cookie to request new urls such as update_password, it seems that I can keep doing it even after I logout:

Jiang-Nans-MacBook-Retina:backend jiangnan$ curl -i --request GET --url http://127.0.0.1:9433/api/auth/logout -H 'Cookie: auth=b8bPZB3TU8MamnU9pWcEkBCEPRRLRXUesKFL51ifnFQ1hV4Hwd3DKF9jPuOKbJbT;'
HTTP/1.1 200 OK
content-length: 0
set-cookie: auth=; HttpOnly; Path=/; Domain=localhost; Max-Age=0; Expires=Fri, 27 Dec 2019 08:25:02 GMT
date: Sat, 26 Dec 2020 08:25:02 GMT

Jiang-Nans-MacBook-Retina:backend jiangnan$ curl -i --request POST   --url http://127.0.0.1:9433/api/auth/update_password --header 'content-type: application/json;' -H 'Cookie: auth=b8bPZB3TU8MamnU9pWcEkBCEPRRLRXUesKFL51ifnFQ1hV4Hwd3DKF9jPuOKbJbT;' --data '{
        "old_password": "12345",
        "new_password":"12345"
}'
HTTP/1.1 200 OK
content-length: 0
set-cookie: auth=NBq6sx5B5vgexv0N3R3gmGTju5BS4Y2tn7JGhVQi5hU8hIVLYgBYAi9TfWOajrC/; HttpOnly; Path=/; Domain=localhost; Max-Age=86400
date: Sat, 26 Dec 2020 08:25:21 GMT

In the debug mode, I can confirm that id.forget(); in the logout function has indeed been run and the id.id field is set to None. However, there seems to be no real effect after that since I can call the logout API again and again. By the way, where is data for username and cookie saved? Why is cookie still valid even after I restart the server? How can I use the authentication cookie correctly?

yjiangnan avatar Dec 26 '20 09:12 yjiangnan