Log x-webobjects-remote-host in login process

Most of the time, the remote-host will contain data from the x-forwarded-for header.
Which could have more than one ip in it if the request went through multiple proxies.
eg. x-forwarded-for: real.client.ip, load.balancer.ip
pull/10/head
Jean Raby 2013-02-06 09:23:47 -05:00
parent feb02c54b9
commit f8387b90ff
1 changed files with 7 additions and 3 deletions

View File

@ -182,7 +182,7 @@
SOGoUserDefaults *ud;
SOGoSystemDefaults *sd;
SOGoUser *loggedInUser;
NSString *username, *password, *language, *domain;
NSString *username, *password, *language, *domain, *remoteHost;
NSArray *supportedLanguages;
SOGoPasswordPolicyError err;
@ -200,6 +200,9 @@
language = [request formValueForKey: @"language"];
rememberLogin = [[request formValueForKey: @"rememberLogin"] boolValue];
domain = [request formValueForKey: @"domain"];
/* this will always be set to something more or less useful by
* [WOHttpTransaction applyAdaptorHeadersWithHttpRequest] */
remoteHost = [request headerForKey:@"x-webobjects-remote-host"];
if ((b = [auth checkLogin: username password: password domain: &domain
perr: &err expire: &expire grace: &grace useCache: NO])
@ -211,7 +214,7 @@
{
NSDictionary *json;
[self logWithFormat: @"successful login for user '%@' - expire = %d grace = %d", username, expire, grace];
[self logWithFormat: @"successful login from '%@' for user '%@' - expire = %d grace = %d", remoteHost, username, expire, grace];
json = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt: expire], @"expire",
[NSNumber numberWithInt: grace], @"grace", nil];
@ -248,7 +251,8 @@
}
else
{
[self logWithFormat: @"Login for user '%@' might not have worked - password policy: %d grace: %d expire: %d bound: %d", username, err, grace, expire, b];
[self logWithFormat:@"Login from '%@' for user '%@' might not have worked - password policy: %d grace: %d expire: %d bound: %d",
remoteHost, username, err, grace, expire, b];
response = [self _responseWithLDAPPolicyError: err];
}