Ticket #3211 (new defect)
IP check too strict
| Reported by: | bbrazil | Owned by: | jonas |
|---|---|---|---|
| Priority: | low | Milestone: | 2.0 |
| Component: | general | Version: | devel |
| Severity: | normal | Keywords: | consider |
| Cc: | dalius@… |
Description
In trac/web/auth.py the IP check against cookies/sessions requries the exact same IP. This doesn't work for NAT over multiple IP addresses, or using multiple proxies which makes login impossible. The solution is to check only the /24.
Patch (implementation by Dinko Korunic):
--- trac/web/auth.py (revision 3356)
+++ trac/web/auth.py (working copy)
@@ -166,9 +166,11 @@
db = self.env.get_db_cnx()
cursor = db.cursor()
if self.check_ip:
+ ipaddr = '.'.join(req.remote_addr.split('.')[:-1])
+ ipaddr = ipaddr + '%'
cursor.execute("SELECT name FROM auth_cookie "
- "WHERE cookie=%s AND ipnr=%s",
- (cookie.value, req.remote_addr))
+ "WHERE cookie=%s AND ipnr LIKE %s",
+ (cookie.value, ipaddr))
else:
cursor.execute("SELECT name FROM auth_cookie WHERE cookie=%s",
(cookie.value,))
This is related to #1485
Attachments
Change History
Note: See
TracTickets for help on using
tickets.


