Browse Source

Add logging to Auth Proxy

CauseFX 6 years ago
parent
commit
124c56d68f
1 changed files with 14 additions and 7 deletions
  1. 14 7
      api/functions/api-functions.php

+ 14 - 7
api/functions/api-functions.php

@@ -91,13 +91,20 @@ function login($array)
 		$authSuccess = false;
 		$authProxy = false;
 		if($GLOBALS['authProxyEnabled'] && $GLOBALS['authProxyHeaderName'] !== '' && $GLOBALS['authProxyWhitelist'] !== ''){
-
-			$whitelistRange = analyzeIP($GLOBALS['authProxyWhitelist']);
-			$from = $whitelistRange['from'];
-			$to = $whitelistRange['to'];
-			$authProxy = authProxyRangeCheck($from,$to);
-			$usernameHeader = isset(getallheaders()[$GLOBALS['authProxyHeaderName']]) ? getallheaders()[$GLOBALS['authProxyHeaderName']] : $username;
-			$username = ($authProxy) ? $usernameHeader : $username;
+			if(isset(getallheaders()[$GLOBALS['authProxyHeaderName']])){
+				$usernameHeader = isset(getallheaders()[$GLOBALS['authProxyHeaderName']]) ? getallheaders()[$GLOBALS['authProxyHeaderName']] : $username;
+				writeLog('success', 'Auth Proxy Function - Starting Verification for IP: ' . userIP() . ' against IP/Subnet: ' . $GLOBALS['authProxyWhitelist'], $usernameHeader);
+				$whitelistRange = analyzeIP($GLOBALS['authProxyWhitelist']);
+				$from = $whitelistRange['from'];
+				$to = $whitelistRange['to'];
+				$authProxy = authProxyRangeCheck($from,$to);
+				$username = ($authProxy) ? $usernameHeader : $username;
+				if($authProxy){
+					writeLog('success', 'Auth Proxy Function - IP: ' . userIP() . ' has been verified', $usernameHeader);
+				}else{
+					writeLog('error', 'Auth Proxy Function - IP: ' . userIP() . ' has failed verification', $usernameHeader);
+				}
+			}
 		}
 		$function = 'plugin_auth_' . $GLOBALS['authBackend'];
 		if (!$oAuth) {