Changeset 8804


Ignore:
Timestamp:
04/09/13 12:00:39 (6 years ago)
Author:
mnagni
Message:

Incomplete - # 22737: [CEDA Site Python Port] Resource Registration - Make Agreement Docs PDFs
 http://team.ceda.ac.uk/trac/ceda/ticket/22737
Incomplete - # 22802: [CEDA Site Python Port] Login - no message is displayed when the user enters the wrong password
 http://team.ceda.ac.uk/trac/ceda/ticket/22802

Retrieves more simply the remote client address

Location:
mauRepo/dj_security/trunk/dj_security
Files:
1 deleted
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/dj_security/trunk/dj_security/middleware.py

    r8802 r8804  
    8282    def process_response(self, request, response): 
    8383        return response                 
    84      
    85 def _calculate_remote_ip(url_path):    
    86     remote_url = urlparse.urlparse(url_path) 
    87     LOGGER.debug("calculating remote_ip for %s" % (str(remote_url))) 
    88     port = 80 
    89     host = None 
    90     if remote_url.netloc: 
    91         host = remote_url.netloc 
    92     elif remote_url.path: 
    93         host = remote_url.path 
    94          
    95     if not host: 
    96         return None 
    97      
    98     if ':' in host: 
    99         host, port = host.split(':') 
    100     addrinfo = socket.getaddrinfo(host, int(port)) 
    101     LOGGER.info("%s has remote_ip %s" % (url_path, addrinfo[0][-1][0]))                                  
    102     return addrinfo[0][-1][0] 
    10384 
    10485def get_user_byuserkey(user_id): 
     
    130111 
    131112def _encode_authenticated_response(request, response, redirect_to, user):     
    132     remote_ip = _calculate_remote_ip(redirect_to) 
     113    remote_ip = request.environ.get('REMOTE_ADDR') 
    133114    LOGGER.info("responding to remote_ip: %s" % (remote_ip))       
    134115    return _generate_auth_cookie(user, remote_ip, response)         
Note: See TracChangeset for help on using the changeset viewer.