Browse Source

Fixed Proxy-Auth not allowing email only (#1771)

CauseFX 4 years ago
parent
commit
af3f03bad9
1 changed files with 5 additions and 4 deletions
  1. 5 4
      api/classes/organizr.class.php

+ 5 - 4
api/classes/organizr.class.php

@@ -2756,15 +2756,16 @@ class Organizr
 			return false;
 		}
 		// Check if Auth Proxy is enabled
-		if ($this->config['authProxyEnabled'] && $this->config['authProxyHeaderName'] !== '' && $this->config['authProxyWhitelist'] !== '') {
-			if (isset($this->getallheaders()[$this->config['authProxyHeaderName']])) {
+		if ($this->config['authProxyEnabled'] && ($this->config['authProxyHeaderName'] !== '' || $this->config['authProxyHeaderNameEmail'] !== '') && $this->config['authProxyWhitelist'] !== '') {
+			if (isset($this->getallheaders()[$this->config['authProxyHeaderName']]) || isset($this->getallheaders()[$this->config['authProxyHeaderNameEmail']])) {
 				$usernameHeader = $this->getallheaders()[$this->config['authProxyHeaderName']] ?? $username;
 				$emailHeader = $this->getallheaders()[$this->config['authProxyHeaderNameEmail']] ?? null;
-				$this->setLoggerChannel('Authentication', $usernameHeader);
+				$headerForLogin = $emailHeader ?: $usernameHeader;
+				$this->setLoggerChannel('Authentication', $headerForLogin);
 				$this->logger->debug('Starting Auth Proxy verification');
 				$whitelistRange = $this->analyzeIP($this->config['authProxyWhitelist']);
 				$authProxy = $this->authProxyRangeCheck($whitelistRange['from'], $whitelistRange['to']);
-				$username = ($authProxy) ? $usernameHeader : $username;
+				$username = ($authProxy) ? $headerForLogin : $username;
 				$password = ($password == null) ? $this->random_ascii_string(10) : $password;
 				$addEmailToAuthProxy = ($authProxy && $emailHeader) ? ['email' => $emailHeader] : true;
 				if ($authProxy) {