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].

drh 2011-03-16 11:19 UTC trunk
Commit 84e755e2139ca9cc2396c2cfa950f2ccffae1a61
1 file changed +3 -3
+3 -3
--- src/login.c
+++ src/login.c
@@ -255,11 +255,11 @@
255255
cgi_set_cookie(zCookieName, zCookie, 0, expires);
256256
record_login_attempt(zUsername, zIpAddr, 1);
257257
db_multi_exec(
258258
"UPDATE user SET cookie=%Q, ipaddr=%Q, "
259259
" cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
260
- zCookie, zIpAddr, expires, uid
260
+ zCookie, ipPrefix(zIpAddr), expires, uid
261261
);
262262
redirect_to_g();
263263
}
264264
}
265265
style_header("Login/Logout");
@@ -400,11 +400,11 @@
400400
"SELECT uid FROM user"
401401
" WHERE uid=%d"
402402
" AND cookie=%Q"
403403
" AND ipaddr=%Q"
404404
" AND cexpire>julianday('now')",
405
- atoi(zCookie), zCookie, zRemoteAddr
405
+ atoi(zCookie), zCookie, ipPrefix(zRemoteAddr)
406406
);
407407
}else if( memcmp(zCookie,"anon/",5)==0 ){
408408
/* Cookies of the form "anon/TIME/HASH". The TIME must not be
409409
** too old and the sha1 hash of TIME+IPADDR+SECRET must match HASH.
410410
** SECRET is the "captcha-secret" value in the repository.
@@ -754,11 +754,11 @@
754754
cgi_set_cookie(zCookieName, zCookie, 0, expires);
755755
record_login_attempt(zUsername, zIpAddr, 1);
756756
db_multi_exec(
757757
"UPDATE user SET cookie=%Q, ipaddr=%Q, "
758758
" cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
759
- zCookie, zIpAddr, expires, uid
759
+ zCookie, ipPrefix(zIpAddr), expires, uid
760760
);
761761
redirect_to_g();
762762
763763
}
764764
}
765765
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button