Browse Source

added debug logging to OAuth pre-checks

CauseFX 3 years ago
parent
commit
7c2d859d20
1 changed files with 17 additions and 3 deletions
  1. 17 3
      api/classes/organizr.class.php

+ 17 - 3
api/classes/organizr.class.php

@@ -335,9 +335,23 @@ class Organizr
 	public function checkForOrganizrOAuth()
 	{
 		// Oauth?
-		if ($this->config['authProxyEnabled'] && ($this->config['authProxyHeaderName'] !== '' || $this->config['authProxyHeaderNameEmail'] !== '') && $this->config['authProxyWhitelist'] !== '') {
-			if (isset(getallheaders()[$this->config['authProxyHeaderName']]) || isset(getallheaders()[$this->config['authProxyHeaderNameEmail']])) {
-				$this->coookieSeconds('set', 'organizrOAuth', 'true', 20000, false);
+		if ($this->user['groupID'] == '999') {
+			$this->setLoggerChannel('OAuth')->debug('Starting OAuth login check');
+			$data = [
+				'enabled' => $this->config['authProxyEnabled'],
+				'header_name' => $this->config['authProxyHeaderName'],
+				'header_name_email' => $this->config['authProxyHeaderNameEmail'],
+				'whitelist' => $this->config['authProxyWhitelist'],
+			];
+			if ($this->config['authProxyEnabled'] && ($this->config['authProxyHeaderName'] !== '' || $this->config['authProxyHeaderNameEmail'] !== '') && $this->config['authProxyWhitelist'] !== '') {
+				if (isset(getallheaders()[$this->config['authProxyHeaderName']]) || isset(getallheaders()[$this->config['authProxyHeaderNameEmail']])) {
+					$this->coookieSeconds('set', 'organizrOAuth', 'true', 20000, false);
+					$this->setLoggerChannel('OAuth')->info('OAuth pre-check passed - adding organizrOAuth cookie', $data);
+				} else {
+					$this->setLoggerChannel('OAuth')->debug('Header not set', $data);
+				}
+			} else {
+				$this->setLoggerChannel('OAuth')->debug('OAuth not triggered', $data);
 			}
 		}
 	}