Fossil SCM
Only record the first 16 bits of the IP address as part of the login cookie. This allows users with shifting IP addresses to stay logged in. Hopefully, this will address ticket [305143bd876f6].
Commit
84e755e2139ca9cc2396c2cfa950f2ccffae1a61
Parent
302213ed1244867…
1 file changed
+3
-3
+3
-3
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -255,11 +255,11 @@ | ||
| 255 | 255 | cgi_set_cookie(zCookieName, zCookie, 0, expires); |
| 256 | 256 | record_login_attempt(zUsername, zIpAddr, 1); |
| 257 | 257 | db_multi_exec( |
| 258 | 258 | "UPDATE user SET cookie=%Q, ipaddr=%Q, " |
| 259 | 259 | " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d", |
| 260 | - zCookie, zIpAddr, expires, uid | |
| 260 | + zCookie, ipPrefix(zIpAddr), expires, uid | |
| 261 | 261 | ); |
| 262 | 262 | redirect_to_g(); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | style_header("Login/Logout"); |
| @@ -400,11 +400,11 @@ | ||
| 400 | 400 | "SELECT uid FROM user" |
| 401 | 401 | " WHERE uid=%d" |
| 402 | 402 | " AND cookie=%Q" |
| 403 | 403 | " AND ipaddr=%Q" |
| 404 | 404 | " AND cexpire>julianday('now')", |
| 405 | - atoi(zCookie), zCookie, zRemoteAddr | |
| 405 | + atoi(zCookie), zCookie, ipPrefix(zRemoteAddr) | |
| 406 | 406 | ); |
| 407 | 407 | }else if( memcmp(zCookie,"anon/",5)==0 ){ |
| 408 | 408 | /* Cookies of the form "anon/TIME/HASH". The TIME must not be |
| 409 | 409 | ** too old and the sha1 hash of TIME+IPADDR+SECRET must match HASH. |
| 410 | 410 | ** SECRET is the "captcha-secret" value in the repository. |
| @@ -754,11 +754,11 @@ | ||
| 754 | 754 | cgi_set_cookie(zCookieName, zCookie, 0, expires); |
| 755 | 755 | record_login_attempt(zUsername, zIpAddr, 1); |
| 756 | 756 | db_multi_exec( |
| 757 | 757 | "UPDATE user SET cookie=%Q, ipaddr=%Q, " |
| 758 | 758 | " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d", |
| 759 | - zCookie, zIpAddr, expires, uid | |
| 759 | + zCookie, ipPrefix(zIpAddr), expires, uid | |
| 760 | 760 | ); |
| 761 | 761 | redirect_to_g(); |
| 762 | 762 | |
| 763 | 763 | } |
| 764 | 764 | } |
| 765 | 765 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -255,11 +255,11 @@ | |
| 255 | cgi_set_cookie(zCookieName, zCookie, 0, expires); |
| 256 | record_login_attempt(zUsername, zIpAddr, 1); |
| 257 | db_multi_exec( |
| 258 | "UPDATE user SET cookie=%Q, ipaddr=%Q, " |
| 259 | " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d", |
| 260 | zCookie, zIpAddr, expires, uid |
| 261 | ); |
| 262 | redirect_to_g(); |
| 263 | } |
| 264 | } |
| 265 | style_header("Login/Logout"); |
| @@ -400,11 +400,11 @@ | |
| 400 | "SELECT uid FROM user" |
| 401 | " WHERE uid=%d" |
| 402 | " AND cookie=%Q" |
| 403 | " AND ipaddr=%Q" |
| 404 | " AND cexpire>julianday('now')", |
| 405 | atoi(zCookie), zCookie, zRemoteAddr |
| 406 | ); |
| 407 | }else if( memcmp(zCookie,"anon/",5)==0 ){ |
| 408 | /* Cookies of the form "anon/TIME/HASH". The TIME must not be |
| 409 | ** too old and the sha1 hash of TIME+IPADDR+SECRET must match HASH. |
| 410 | ** SECRET is the "captcha-secret" value in the repository. |
| @@ -754,11 +754,11 @@ | |
| 754 | cgi_set_cookie(zCookieName, zCookie, 0, expires); |
| 755 | record_login_attempt(zUsername, zIpAddr, 1); |
| 756 | db_multi_exec( |
| 757 | "UPDATE user SET cookie=%Q, ipaddr=%Q, " |
| 758 | " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d", |
| 759 | zCookie, zIpAddr, expires, uid |
| 760 | ); |
| 761 | redirect_to_g(); |
| 762 | |
| 763 | } |
| 764 | } |
| 765 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -255,11 +255,11 @@ | |
| 255 | cgi_set_cookie(zCookieName, zCookie, 0, expires); |
| 256 | record_login_attempt(zUsername, zIpAddr, 1); |
| 257 | db_multi_exec( |
| 258 | "UPDATE user SET cookie=%Q, ipaddr=%Q, " |
| 259 | " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d", |
| 260 | zCookie, ipPrefix(zIpAddr), expires, uid |
| 261 | ); |
| 262 | redirect_to_g(); |
| 263 | } |
| 264 | } |
| 265 | style_header("Login/Logout"); |
| @@ -400,11 +400,11 @@ | |
| 400 | "SELECT uid FROM user" |
| 401 | " WHERE uid=%d" |
| 402 | " AND cookie=%Q" |
| 403 | " AND ipaddr=%Q" |
| 404 | " AND cexpire>julianday('now')", |
| 405 | atoi(zCookie), zCookie, ipPrefix(zRemoteAddr) |
| 406 | ); |
| 407 | }else if( memcmp(zCookie,"anon/",5)==0 ){ |
| 408 | /* Cookies of the form "anon/TIME/HASH". The TIME must not be |
| 409 | ** too old and the sha1 hash of TIME+IPADDR+SECRET must match HASH. |
| 410 | ** SECRET is the "captcha-secret" value in the repository. |
| @@ -754,11 +754,11 @@ | |
| 754 | cgi_set_cookie(zCookieName, zCookie, 0, expires); |
| 755 | record_login_attempt(zUsername, zIpAddr, 1); |
| 756 | db_multi_exec( |
| 757 | "UPDATE user SET cookie=%Q, ipaddr=%Q, " |
| 758 | " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d", |
| 759 | zCookie, ipPrefix(zIpAddr), expires, uid |
| 760 | ); |
| 761 | redirect_to_g(); |
| 762 | |
| 763 | } |
| 764 | } |
| 765 |