From f8387b90ffd3f016f4a4de88577b1280a84aefc8 Mon Sep 17 00:00:00 2001 From: Jean Raby Date: Wed, 6 Feb 2013 09:23:47 -0500 Subject: [PATCH] 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 --- UI/MainUI/SOGoRootPage.m | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/UI/MainUI/SOGoRootPage.m b/UI/MainUI/SOGoRootPage.m index f28ea533f..fb349ef61 100644 --- a/UI/MainUI/SOGoRootPage.m +++ b/UI/MainUI/SOGoRootPage.m @@ -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]; }