[Zope] Re: Zope User in Apache Logs

Josef Meile jmeile at hotmail.com
Wed May 17 06:43:40 EDT 2006


> I read the answer from Dieter and unfortunately I'm not authenticating
> from Apache. So, I went for the approach indicated by Chris Withers
> without any success:
> 
>  > If your Zope auth solution can put a header in the http response, 
> then > you can use a custom apache logging directive to put this in your
>  > Apache log in place of what it thinks the username is.
> I put this on the "log" method of the medusa/http_server.py file:
> self.response.setHeader('remote_user',name)
> 
> and set my apache access log like this:
> CustomLog /home/apache/httpd/logs/access_log combined
> 
> The combined log is defined as follows:
> LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
> combined
> 
> There you see the %l and %u directives, which are the "Remote logname" 
> and the "Remote user".
> 
> But apache still doesn't get the zope authenticated user. So, Chris, do 
> you remember what header you set, where, and which method you used?
Ok, Answering to this question. I guess I had to set the header inside the
authenticate method of the BasicUserFolder class. Here is what I did:

def authenticate(self, name, password, request):
     emergency = self._emergency_user
     user = None
     if name is None:
         pass
     else:
         if emergency and name==emergency.getUserName():
             user = emergency
         else:
             user = self.getUser(name)
         if user is not None and user.authenticate(password, request):
             pass
         else:
             user = None
      logUser = 'Anonymous'
      if (user != None):
          logUser = user.getUserName()
      request.response.setHeader('remote-user',logUser)
      return user

The header is set, but apache still doesn't get it, so, I guess I'm 
using the wrong name. What header should I use?

Regards
Josef



More information about the Zope mailing list