Changeset 2834
- Timestamp:
- 11/28/07 06:14:29 (8 months ago)
- Files:
-
- authopenidplugin/0.11/authopenid/authopenid.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
authopenidplugin/0.11/authopenid/authopenid.py
r2833 r2834 36 36 from openid import sreg 37 37 38 import socket 39 import struct 40 38 41 class AuthOpenIdPlugin(Component): 39 42 … … 50 53 """Whether the IP address of the user should be checked for 51 54 authentication (''since 0.9'').""") 55 check_ip_mask = Option('trac', 'check_auth_ip_mask', '255.255.255.0', 56 """What mask should be applied to user address.""") 57 58 def _get_masked_address(self, address): 59 mask = struct.unpack('>L', socket.inet_aton(self.check_ip_mask))[0] 60 address = struct.unpack('>L', socket.inet_aton(address))[0] 61 return socket.inet_ntoa(struct.pack('>L', address & mask)) 52 62 53 63 def __init__(self): … … 275 285 cursor.execute("INSERT INTO auth_cookie (cookie,name,ipnr,time) " 276 286 "VALUES (%s, %s, %s, %s)", (cookie, remote_user, 277 req.remote_addr, int(time.time())))287 self._get_masked_address(req.remote_addr), int(time.time()))) 278 288 db.commit() 279 289 … … 363 373 cursor.execute("SELECT name FROM auth_cookie " 364 374 "WHERE cookie=%s AND ipnr=%s", 365 (cookie.value, req.remote_addr))375 (cookie.value, self._get_masked_address(req.remote_addr))) 366 376 else: 367 377 cursor.execute("SELECT name FROM auth_cookie WHERE cookie=%s",
