Ignore:
Timestamp:
13/12/12 09:01:22 (7 years ago)
Author:
mnagni
Message:

Adds few logging

File:
1 edited

Legend:

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

    r8707 r8710  
    6161     
    6262    def process_response(self, request, response): 
     63        LOGGER.debug("responding to request.path: %s" % (request.path))  
    6364        session = getattr(request, 'session', None) 
    6465         
     
    7475 
    7576        if request.path == '/account/signin/complete/' and not request.session.get('done', False): 
    76             return _encode_authenticated_response(request) 
     77            return _encode_authenticated_response(request, response) 
    7778 
    78         if request.path == '/account/signin/complete/' and request.session.get('done', False): 
    79             return response 
     79        #if request.path == '/account/signin/complete/' and request.session.get('done', False): 
     80        #    return response 
    8081         
    81         remote_ip = _calculate_remote_ip(base64.b64decode(request.session.get('r'))) 
    82         LOGGER.debug("responding to remote_ip: %s" % (remote_ip))  
    83         username = session.get('openid').openid 
    84         user = get_user_byopenid(username) 
    85          
    86         token = AuthTicket( 
    87                     getattr(settings, 'SHARED_SECRET', 'sharedsecret'),  
    88                     username,  
    89                     remote_ip,  
    90                     user_data = '{"userkey": "%s"}' % (user.userkey))                
    91         LOGGER.debug("Created authTicket for %s from %s" % (username, remote_ip)) 
    92         response.set_cookie('auth_tkt',  
    93                             token.cookie_value(),  
    94                             domain = getattr(settings, 'COOKIE_DOMAIN', None)) 
    95         LOGGER.debug("Set authTicket in response for %s from %s" % (username, remote_ip)) 
    9682        return response 
    9783         
     
    11399        host, port = host.split(':') 
    114100    addrinfo = socket.getaddrinfo(host, int(port)) 
    115     LOGGER.debug("%s has remote_ip %s" % (url_path, addrinfo[0][-1][0]))                                  
     101    LOGGER.info("%s has remote_ip %s" % (url_path, addrinfo[0][-1][0]))                                  
    116102    return addrinfo[0][-1][0] 
    117103 
     
    128114        raise DSJOpenIDNotFoundError(ex)   
    129115 
    130 def _encode_authenticated_response(request, context = {}): 
    131     request.session['done'] = True 
    132     redirect_parameter = getattr(settings, 'REDIRECT_URL', 'r')     
     116def _encode_authenticated_response(request, response, context = {}): 
     117    remote_ip = _calculate_remote_ip(base64.b64decode(request.session.get('r'))) 
     118    LOGGER.info("responding to remote_ip: %s" % (remote_ip))  
     119    username = request.session.get('openid').openid 
     120    user = get_user_byopenid(username) 
     121     
     122    token = AuthTicket( 
     123                getattr(settings, 'SHARED_SECRET', 'sharedsecret'),  
     124                username,  
     125                remote_ip,  
     126                user_data = '{"userkey": "%s"}' % (user.userkey))                
     127    LOGGER.info("Created authTicket for %s from %s" % (username, remote_ip)) 
     128    response.set_cookie('auth_tkt',  
     129                        token.cookie_value(),  
     130                        domain = getattr(settings, 'COOKIE_DOMAIN', None)) 
     131    LOGGER.debug("Set authTicket in response for %s from %s" % (username, remote_ip)) 
     132    redirect_parameter = getattr(settings, 'REDIRECT_URL', 'r') 
    133133    context['redirect_url'] = base64.b64decode(request.session.get(redirect_parameter, '')) 
    134134    return render_to_response('logged_in.html', context) 
Note: See TracChangeset for help on using the changeset viewer.